Merge branch 'stable-2.14' into stable-2.15

* stable-2.14:
  Update jruby to 9.1.17 and asciidoctorj to v1.5.7
  Elasticsearch: Ensure request URI is always prefixed with "/"
  AbstractElasticIndex: Factor out more variants of {post,perform}Request
  rest-api-projects: Fix "unterminated listing block" warning
  config-gerrit: Fix "invalid reference: database.h2.cachesize" warning
  Bazel: Specify name for downloaded file to http_file starlark rule
  Set version to 2.14.14-SNAPSHOT

Change-Id: I8a3bf774120fadea7c52871047b99631e2a798de
This commit is contained in:
Paladox 2018-09-26 19:45:42 +01:00 committed by Paladox none
commit 12c05a268f
11 changed files with 43 additions and 33 deletions

View File

@ -674,7 +674,7 @@ H2 uses memory to cache its database content. The parameter `h2CacheSize`
allows to limit the memory used by H2 and thus prevent out-of-memory
caused by the H2 database using too much memory.
+
See <<database.h2.cachesize,database.h2.cachesize>> for a detailed discussion.
See <<database.h2.cacheSize,database.h2.cacheSize>> for a detailed discussion.
+
Default is unset, using up to half of the available memory.
+

View File

@ -3301,8 +3301,6 @@ The path to the `GerritSiteHeader.html` file.
The path to the `GerritSiteFooter.html` file.
|=============================
----
GERRIT
------
Part of link:index.html[Gerrit Code Review]

View File

@ -24,6 +24,7 @@ http_archive(
# https://github.com/google/closure-compiler/blob/master/contrib/externs/polymer-1.0.js
http_file(
name = "polymer_closure",
downloaded_file_path = "polymer_closure.js",
sha256 = "5a589bdba674e1fec7188e9251c8624ebf2d4d969beb6635f9148f420d1e08b1",
urls = ["https://raw.githubusercontent.com/google/closure-compiler/775609aad61e14aef289ebec4bfc09ad88877f9e/contrib/externs/polymer-1.0.js"],
)
@ -867,14 +868,14 @@ maven_jar(
maven_jar(
name = "asciidoctor",
artifact = "org.asciidoctor:asciidoctorj:1.5.6",
sha1 = "bb757d4b8b0f8438ce2ed781f6688cc6c01d9237",
artifact = "org.asciidoctor:asciidoctorj:1.5.7",
sha1 = "8e8c1d8fc6144405700dd8df3b177f2801ac5987",
)
maven_jar(
name = "jruby",
artifact = "org.jruby:jruby-complete:9.1.13.0",
sha1 = "8903bf42272062e87a7cbc1d98919e0729a9939f",
artifact = "org.jruby:jruby-complete:9.1.17.0",
sha1 = "76716d529710fc03d1d429b43e3cedd4419f78d4",
)
maven_jar(

View File

@ -3,6 +3,7 @@ java_library(
srcs = glob(["src/main/java/**/*.java"]),
visibility = ["//visibility:public"],
deps = [
"//gerrit-common:annotations",
"//gerrit-extension-api:api",
"//gerrit-index:index",
"//gerrit-index:query_exception",

View File

@ -21,6 +21,7 @@ import static org.apache.commons.codec.binary.Base64.decodeBase64;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.CharStreams;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.elasticsearch.ElasticMapping.MappingProperties;
import com.google.gerrit.elasticsearch.builders.SearchSourceBuilder;
import com.google.gerrit.elasticsearch.bulk.DeleteRequest;
@ -135,7 +136,7 @@ abstract class AbstractElasticIndex<K, V> implements Index<K, V> {
@Override
public void delete(K id) throws IOException {
String uri = getURI(type, BULK);
Response response = postRequest(getDeleteActions(id), uri, getRefreshParam());
Response response = postRequest(uri, getDeleteActions(id), getRefreshParam());
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode != HttpStatus.SC_OK) {
throw new IOException(
@ -147,10 +148,10 @@ abstract class AbstractElasticIndex<K, V> implements Index<K, V> {
public void deleteAll() throws IOException {
// Delete the index, if it exists.
String endpoint = indexName + client.adapter().indicesExistParam();
Response response = client.get().performRequest(new Request("HEAD", endpoint));
Response response = performRequest("HEAD", endpoint);
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode == HttpStatus.SC_OK) {
response = client.get().performRequest(new Request("DELETE", indexName));
response = performRequest("DELETE", indexName);
statusCode = response.getStatusLine().getStatusCode();
if (statusCode != HttpStatus.SC_OK) {
throw new IOException(
@ -160,7 +161,7 @@ abstract class AbstractElasticIndex<K, V> implements Index<K, V> {
// Recreate the index.
String indexCreationFields = concatJsonString(getSettings(), getMappings());
response = performRequest("PUT", indexCreationFields, indexName, Collections.emptyMap());
response = performRequest("PUT", indexName, indexCreationFields);
statusCode = response.getStatusLine().getStatusCode();
if (statusCode != HttpStatus.SC_OK) {
String error = String.format("Failed to create index %s: %s", indexName, statusCode);
@ -228,20 +229,36 @@ abstract class AbstractElasticIndex<K, V> implements Index<K, V> {
return encodedIndexName + "/" + encodedType + "/" + request;
}
protected Response postRequest(Object payload, String uri, Map<String, String> params)
protected Response postRequest(String uri, Object payload) throws IOException {
return performRequest("POST", uri, payload);
}
protected Response postRequest(String uri, Object payload, Map<String, String> params)
throws IOException {
return performRequest("POST", payload, uri, params);
return performRequest("POST", uri, payload, params);
}
private String concatJsonString(String target, String addition) {
return target.substring(0, target.length() - 1) + "," + addition.substring(1);
}
private Response performRequest(String method, String uri) throws IOException {
return performRequest(method, uri, null);
}
private Response performRequest(String method, String uri, @Nullable Object payload)
throws IOException {
return performRequest(method, uri, payload, Collections.emptyMap());
}
private Response performRequest(
String method, Object payload, String uri, Map<String, String> params) throws IOException {
Request request = new Request(method, uri);
String payloadStr = payload instanceof String ? (String) payload : payload.toString();
request.setEntity(new NStringEntity(payloadStr, ContentType.APPLICATION_JSON));
String method, String uri, @Nullable Object payload, Map<String, String> params)
throws IOException {
Request request = new Request(method, uri.startsWith("/") ? uri : "/" + uri);
if (payload != null) {
String payloadStr = payload instanceof String ? (String) payload : payload.toString();
request.setEntity(new NStringEntity(payloadStr, ContentType.APPLICATION_JSON));
}
for (Map.Entry<String, String> entry : params.entrySet()) {
request.addParameter(entry.getKey(), entry.getValue());
}

View File

@ -93,7 +93,7 @@ public class ElasticAccountIndex extends AbstractElasticIndex<Account.Id, Accoun
.add(new UpdateRequest<>(schema, as));
String uri = getURI(type, BULK);
Response response = postRequest(bulk, uri, getRefreshParam());
Response response = postRequest(uri, bulk, getRefreshParam());
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode != HttpStatus.SC_OK) {
throw new IOException(
@ -152,7 +152,7 @@ public class ElasticAccountIndex extends AbstractElasticIndex<Account.Id, Accoun
try {
List<AccountState> results = Collections.emptyList();
String uri = getURI(type, SEARCH);
Response response = postRequest(search, uri, Collections.emptyMap());
Response response = postRequest(uri, search);
StatusLine statusLine = response.getStatusLine();
if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
String content = getContent(response);

View File

@ -146,7 +146,7 @@ class ElasticChangeIndex extends AbstractElasticIndex<Change.Id, ChangeData>
}
String uri = getURI(type, BULK);
Response response = postRequest(bulk, uri, getRefreshParam());
Response response = postRequest(uri, bulk, getRefreshParam());
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode != HttpStatus.SC_OK) {
throw new IOException(
@ -227,7 +227,7 @@ class ElasticChangeIndex extends AbstractElasticIndex<Change.Id, ChangeData>
try {
List<ChangeData> results = Collections.emptyList();
String uri = getURI(types);
Response response = postRequest(search, uri, Collections.emptyMap());
Response response = postRequest(uri, search);
StatusLine statusLine = response.getStatusLine();
if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
String content = getContent(response);

View File

@ -92,7 +92,7 @@ public class ElasticGroupIndex extends AbstractElasticIndex<AccountGroup.UUID, I
.add(new UpdateRequest<>(schema, group));
String uri = getURI(type, BULK);
Response response = postRequest(bulk, uri, getRefreshParam());
Response response = postRequest(uri, bulk, getRefreshParam());
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode != HttpStatus.SC_OK) {
throw new IOException(
@ -151,7 +151,7 @@ public class ElasticGroupIndex extends AbstractElasticIndex<AccountGroup.UUID, I
try {
List<InternalGroup> results = Collections.emptyList();
String uri = getURI(type, SEARCH);
Response response = postRequest(search, uri, Collections.emptyMap());
Response response = postRequest(uri, search);
StatusLine statusLine = response.getStatusLine();
if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
String content = getContent(response);

View File

@ -32,7 +32,7 @@ public class ElasticQueryAdapter {
ElasticQueryAdapter(ElasticVersion version) {
this.ignoreUnmapped = version == ElasticVersion.V2_4;
this.usePostV5Type = version.isV6();
this.versionDiscoveryUrl = version.isV6() ? "%s*" : "%s*/_aliases";
this.versionDiscoveryUrl = version.isV6() ? "/%s*" : "/%s*/_aliases";
switch (version) {
case V5_6:

View File

@ -107,7 +107,7 @@ class ElasticRestClientProvider implements Provider<RestClient>, LifecycleListen
private ElasticVersion getVersion() throws ElasticException {
try {
Response response = client.performRequest(new Request("GET", ""));
Response response = client.performRequest(new Request("GET", "/"));
StatusLine statusLine = response.getStatusLine();
if (statusLine.getStatusCode() != HttpStatus.SC_OK) {
throw new FailedToGetVersion(statusLine);

View File

@ -18,16 +18,9 @@ package(
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library")
genrule(
name = "polymer_closure_renamed",
srcs = ["@polymer_closure//file"],
outs = ["polymer_closure_renamed.js"],
cmd = "cp $< $@",
)
closure_js_library(
name = "polymer_closure",
srcs = [":polymer_closure_renamed"],
srcs = ["@polymer_closure//file"],
data = ["//lib:LICENSE-Apache2.0"],
no_closure_library = True,
)