Skip to content

Commit b5ae5ba

Browse files
committed
Merge branch 'master' into feature/searchable-snapshots
2 parents 61e6029 + 68c739f commit b5ae5ba

File tree

218 files changed

+3782
-2458
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

218 files changed

+3782
-2458
lines changed

.ci/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
JAVA_HOME=${JAVA_HOME:-$HOME/.java/openjdk12}
3+
JAVA_HOME=${JAVA_HOME:-$HOME/.java/openjdk13}
44
RUNTIME_JAVA_HOME=${RUNTIME_JAVA_HOME:-$HOME/.java/openjdk11}
55

66
JAVA7_HOME=$HOME/.java/java7

.ci/java-versions.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# build and test Elasticsearch for this branch. Valid Java versions
55
# are 'java' or 'openjdk' followed by the major release number.
66

7-
ES_BUILD_JAVA=openjdk12
7+
ES_BUILD_JAVA=openjdk13
88
ES_RUNTIME_JAVA=openjdk11
99
GRADLE_TASK=build
1010

.ci/matrix-build-javas.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
# or 'openjdk' followed by the major release number.
77

88
ES_BUILD_JAVA:
9-
- openjdk12
9+
- openjdk13

.ci/matrix-runtime-javas.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@
77

88
ES_RUNTIME_JAVA:
99
- java11
10-
- java12
11-
- openjdk12
1210
- openjdk13
1311
- openjdk14
1412
- zulu11
15-
- zulu12
1613
- corretto11
1714
- adoptopenjdk11

.ci/packer_cache.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ export JAVA_HOME="${HOME}"/.java/${ES_BUILD_JAVA}
2121
export JAVA8_HOME="${HOME}"/.java/java8
2222
export JAVA11_HOME="${HOME}"/.java/java11
2323
export JAVA12_HOME="${HOME}"/.java/openjdk12
24+
export JAVA13_HOME="${HOME}"/.java/openjdk13
2425
./gradlew --parallel clean --scan -Porg.elasticsearch.acceptScanTOS=true -s resolveAllDependencies
2526

CONTRIBUTING.md

Lines changed: 106 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,22 +92,22 @@ Contributing to the Elasticsearch codebase
9292

9393
**Repository:** [https://github.com/elastic/elasticsearch](https://github.com/elastic/elasticsearch)
9494

95-
JDK 12 is required to build Elasticsearch. You must have a JDK 12 installation
95+
JDK 13 is required to build Elasticsearch. You must have a JDK 13 installation
9696
with the environment variable `JAVA_HOME` referencing the path to Java home for
97-
your JDK 12 installation. By default, tests use the same runtime as `JAVA_HOME`.
97+
your JDK 13 installation. By default, tests use the same runtime as `JAVA_HOME`.
9898
However, since Elasticsearch supports JDK 11, the build supports compiling with
99-
JDK 12 and testing on a JDK 11 runtime; to do this, set `RUNTIME_JAVA_HOME`
99+
JDK 13 and testing on a JDK 11 runtime; to do this, set `RUNTIME_JAVA_HOME`
100100
pointing to the Java home of a JDK 11 installation. Note that this mechanism can
101101
be used to test against other JDKs as well, this is not only limited to JDK 11.
102102

103103
> Note: It is also required to have `JAVA8_HOME`, `JAVA9_HOME`, `JAVA10_HOME`
104-
and `JAVA11_HOME` available so that the tests can pass.
104+
and `JAVA11_HOME`, and `JAVA12_HOME` available so that the tests can pass.
105105

106106
> Warning: do not use `sdkman` for Java installations which do not have proper
107107
`jrunscript` for jdk distributions.
108108

109109
Elasticsearch uses the Gradle wrapper for its build. You can execute Gradle
110-
using the wrapper via the `gradlew` script on Unix systems or `gradlew.bat`
110+
using the wrapper via the `gradlew` script on Unix systems or `gradlew.bat`
111111
script on Windows in the root of the repository. The examples below show the
112112
usage on Unix.
113113

@@ -157,9 +157,9 @@ For IntelliJ, go to
157157
For Eclipse, go to `Preferences->Java->Installed JREs` and add `-ea` to
158158
`VM Arguments`.
159159

160-
Some tests related to locale testing also require the flag
160+
Some tests related to locale testing also require the flag
161161
`-Djava.locale.providers` to be set. Set the VM options/VM arguments for
162-
IntelliJ or Eclipse like describe above to use
162+
IntelliJ or Eclipse like describe above to use
163163
`-Djava.locale.providers=SPI,COMPAT`.
164164

165165
### Java Language Formatting Guidelines
@@ -168,8 +168,8 @@ Java files in the Elasticsearch codebase are formatted with the Eclipse JDT
168168
formatter, using the [Spotless
169169
Gradle](https://github.com/diffplug/spotless/tree/master/plugin-gradle)
170170
plugin. This plugin is configured on a project-by-project basis, via
171-
`build.gradle` in the root of the repository. So long as at least one
172-
project is configured, the formatting check can be run explicitly with:
171+
`build.gradle` in the root of the repository. The formatting check can be
172+
run explicitly with:
173173

174174
./gradlew spotlessJavaCheck
175175

@@ -205,7 +205,7 @@ Please follow these formatting guidelines:
205205
these are intended for use in documentation, so please make it clear what
206206
you have done, and only do this where the benefit clearly outweighs the
207207
decrease in consistency.
208-
* Note that JavaDoc and block comments i.e. `/* ... */` are not formatted,
208+
* Note that Javadoc and block comments i.e. `/* ... */` are not formatted,
209209
but line comments i.e `// ...` are.
210210
* There is an implicit rule that negative boolean expressions should use
211211
the form `foo == false` instead of `!foo` for better readability of the
@@ -231,15 +231,107 @@ from the command line.
231231

232232
Sometimes Spotless will report a "misbehaving rule which can't make up its
233233
mind" and will recommend enabling the `paddedCell()` setting. If you
234-
enabled this settings and run the format check again,
234+
enabled this setting and run the format check again,
235235
Spotless will write files to
236236
`$PROJECT/build/spotless-diagnose-java/` to aid diagnosis. It writes
237237
different copies of the formatted files, so that you can see how they
238238
differ and infer what is the problem.
239239

240-
The `paddedCell()` option is disabled for normal operation in order to
241-
detect any misbehaviour. You can enabled the option from the command line
242-
by running Gradle with `-Dspotless.paddedcell`.
240+
The `paddedCell()` option is disabled for normal operation so that any
241+
misbehaviour is detected, and not just suppressed. You can enabled the
242+
option from the command line by running Gradle with `-Dspotless.paddedcell`.
243+
244+
### Javadoc
245+
246+
Good Javadoc can help with navigating and understanding code. Elasticsearch
247+
has some guidelines around when to write Javadoc and when not to, but note
248+
that we don't want to be overly prescriptive. The intent of these guidelines
249+
is to be helpful, not to turn writing code into a chore.
250+
251+
#### The short version
252+
253+
1. Always add Javadoc to new code.
254+
2. Add Javadoc to existing code if you can.
255+
3. Document the "why", not the "how", unless that's important to the
256+
"why".
257+
4. Don't document anything trivial or obvious (e.g. getters and
258+
setters). In other words, the Javadoc should add some value.
259+
260+
#### The long version
261+
262+
1. If you add a new Java package, please also add package-level
263+
Javadoc that explains what the package is for. This can just be a
264+
reference to a more foundational / parent package if appropriate. An
265+
example would be a package hierarchy for a new feature or plugin -
266+
the package docs could explain the purpose of the feature, any
267+
caveats, and possibly some examples of configuration and usage.
268+
2. New classes and interfaces must have class-level Javadoc that
269+
describes their purpose. There are a lot of classes in the
270+
Elasticsearch repository, and it's easier to navigate when you
271+
can quickly find out what is the purpose of a class. This doesn't
272+
apply to inner classes or interfaces, unless you expect them to be
273+
explicitly used outside their parent class.
274+
3. New public methods must have Javadoc, because they form part of the
275+
contract between the class and its consumers. Similarly, new abstract
276+
methods must have Javadoc because they are part of the contract
277+
between a class and its subclasses. It's important that contributors
278+
know why they need to implement a method, and the Javadoc should make
279+
this clear. You don't need to document a method if it's overriding an
280+
abstract method (either from an abstract superclass or an interface),
281+
unless your implementation is doing something "unexpected" e.g. deviating
282+
from the intent of the original method.
283+
4. Following on from the above point, please add docs to existing public
284+
methods if you are editing them, or to abstract methods if you can.
285+
5. Non-public, non-abstract methods don't require Javadoc, but if you feel
286+
that adding some would make it easier for other developers to
287+
understand the code, or why it's written in a particular way, then please
288+
do so.
289+
6. Properties don't need to have Javadoc, but please add some if there's
290+
something useful to say.
291+
7. Javadoc should not go into low-level implementation details unless
292+
this is critical to understanding the code e.g. documenting the
293+
subtleties of the implementation of a private method. The point here
294+
is that implementations will change over time, and the Javadoc is
295+
less likely to become out-of-date if it only talks about the what is
296+
the purpose of the code, not what it does.
297+
8. Examples in Javadoc can be very useful, so feel free to add some if
298+
you can reasonably do so i.e. if it takes a whole page of code to set
299+
up an example, then Javadoc probably isn't the right place for it.
300+
Longer or more elaborate examples are probably better suited
301+
to the package docs.
302+
9. Test methods are a good place to add Javadoc, because you can use it
303+
to succinctly describe e.g. preconditions, actions and expectations
304+
of the test, more easily that just using the test name alone. Please
305+
consider documenting your tests in this way.
306+
10. Sometimes you shouldn't add Javadoc:
307+
1. Where it adds no value, for example where a method's
308+
implementation is trivial such as with getters and setters, or a
309+
method just delegates to another object.
310+
2. However, you should still add Javadoc if there are caveats around
311+
calling a method that are not immediately obvious from reading the
312+
method's implementation in isolation.
313+
3. You can omit Javadoc for simple classes, e.g. where they are a
314+
simple container for some data. However, please consider whether a
315+
reader might still benefit from some additional background, for
316+
example about why the class exists at all.
317+
11. Not all comments need to be Javadoc. Sometimes it will make more
318+
sense to add comments in a method's body, for example due to important
319+
implementation decisions or "gotchas". As a general guide, if some
320+
information forms part of the contract between a method and its callers,
321+
then it should go in the Javadoc, otherwise you might consider using
322+
regular comments in the code. Remember as well that Elasticsearch
323+
has extensive [user documentation](./docs), and it is not the role
324+
of Javadoc to replace that.
325+
12. Please still try to make class, method or variable names as
326+
descriptive and concise as possible, as opposed to relying solely on
327+
Javadoc to describe something.
328+
13. Use `@link` and `@see` to add references, either to related
329+
resources in the codebase or to relevant external resources.
330+
14. If you need help writing Javadoc, just ask!
331+
332+
Finally, use your judgement! Base your decisions on what will help other
333+
developers - including yourself, when you come back to some code
334+
3 months in the future, having forgotten how it works.
243335

244336
### License Headers
245337

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,9 +672,10 @@ class BuildPlugin implements Plugin<Project> {
672672

673673
test.jvmArgs "-Xmx${System.getProperty('tests.heap.size', '512m')}",
674674
"-Xms${System.getProperty('tests.heap.size', '512m')}",
675-
'--illegal-access=warn'
675+
'--illegal-access=warn',
676+
'-XX:+HeapDumpOnOutOfMemoryError'
676677

677-
test.jvmArgumentProviders.add({ ['-XX:+HeapDumpOnOutOfMemoryError', "-XX:HeapDumpPath=$heapdumpDir"] } as CommandLineArgumentProvider)
678+
test.jvmArgumentProviders.add({ ["-XX:HeapDumpPath=$heapdumpDir"] } as CommandLineArgumentProvider)
678679

679680
if (System.getProperty('tests.jvm.argline')) {
680681
test.jvmArgs System.getProperty('tests.jvm.argline').split(" ")

buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import de.thetaphi.forbiddenapis.gradle.ForbiddenApisPlugin
2424
import org.elasticsearch.gradle.ExportElasticsearchBuildResourcesTask
2525
import org.elasticsearch.gradle.VersionProperties
2626
import org.elasticsearch.gradle.info.BuildParams
27+
import org.gradle.api.JavaVersion
2728
import org.gradle.api.Project
2829
import org.gradle.api.artifacts.Configuration
2930
import org.gradle.api.plugins.JavaBasePlugin
@@ -145,16 +146,13 @@ class PrecommitTasks {
145146
doFirst {
146147
// we need to defer this configuration since we don't know the runtime java version until execution time
147148
targetCompatibility = BuildParams.runtimeJavaVersion.majorVersion
148-
/*
149-
TODO: Reenable once Gradle supports Java 13 or later!
150149
if (BuildParams.runtimeJavaVersion > JavaVersion.VERSION_13) {
151-
project.logger.info(
152-
"Forbidden APIs does not support java version past 13. Will use the signatures from 13 for ",
153-
BuildParams.runtimeJavaVersion`
150+
project.logger.warn(
151+
"Forbidden APIs does not support Java versions past 13. Will use the signatures from 13 for {}.",
152+
BuildParams.runtimeJavaVersion
154153
)
155-
targetCompatibility = JavaVersion.VERSION_13.getMajorVersion()
154+
targetCompatibility = JavaVersion.VERSION_13.majorVersion
156155
}
157-
*/
158156
}
159157
bundledSignatures = [
160158
"jdk-unsafe", "jdk-deprecated", "jdk-non-portable", "jdk-system-out"

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/DistroTestPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public class DistroTestPlugin implements Plugin<Project> {
7575

7676
private static final String SYSTEM_JDK_VERSION = "11.0.2+9";
7777
private static final String SYSTEM_JDK_VENDOR = "openjdk";
78-
private static final String GRADLE_JDK_VERSION = "12.0.1+12@69cfe15208a647278a19ef0990eea691";
78+
private static final String GRADLE_JDK_VERSION = "13.0.1+9@cec27d702aa74d5a8630c65ae61e4305";
7979
private static final String GRADLE_JDK_VENDOR = "openjdk";
8080

8181
// all distributions used by distro tests. this is temporary until tests are per distribution
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
12
1+
13

buildSrc/src/minimumRuntime/java/org/elasticsearch/gradle/info/BuildParams.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ private static <T> T value(T object) {
137137
}
138138

139139
private static String propertyName(String methodName) {
140-
String propertyName = methodName.substring("get".length());
140+
String propertyName = methodName.startsWith("is") ? methodName.substring("is".length()) : methodName.substring("get".length());
141141
return propertyName.substring(0, 1).toLowerCase() + propertyName.substring(1);
142142
}
143143

buildSrc/version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
elasticsearch = 8.0.0
2-
lucene = 8.4.0-snapshot-662c455
2+
lucene = 8.4.0-snapshot-08b8d116f8f
33

44
bundled_jdk_vendor = adoptopenjdk
55
bundled_jdk = 13.0.1+9

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SecurityDocumentationIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,8 +694,8 @@ public void testGetRoles() throws Exception {
694694

695695
List<Role> roles = response.getRoles();
696696
assertNotNull(response);
697-
// 29 system roles plus the three we created
698-
assertThat(roles.size(), equalTo(33));
697+
// 28 system roles plus the three we created
698+
assertThat(roles.size(), equalTo(28 + 3));
699699
}
700700

701701
{

distribution/bwc/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import org.elasticsearch.gradle.Version
2323
import org.elasticsearch.gradle.BwcVersions
2424
import org.elasticsearch.gradle.info.BuildParams
2525
import org.elasticsearch.gradle.info.GlobalBuildInfoPlugin
26+
import org.gradle.util.GradleVersion
2627

2728
import java.nio.charset.StandardCharsets
2829

@@ -161,6 +162,12 @@ bwcVersions.forPreviousUnreleased { BwcVersions.UnreleasedVersionInfo unreleased
161162
spoolOutput = true
162163
workingDir = checkoutDir
163164
doFirst {
165+
// TODO: Remove this once we've updated to Gradle 6.1
166+
// Workaround for https://github.com/gradle/gradle/issues/11426
167+
if (GradleVersion.version(file("${ checkoutDir}/buildSrc/src/main/resources/minimumGradleVersion").text) != GradleVersion.current()) {
168+
environment = environment.findAll { key, val -> key != 'OPENSHIFT_IP' }
169+
}
170+
164171
// Execution time so that the checkouts are available
165172
List<String> lines = file("${checkoutDir}/.ci/java-versions.properties").readLines()
166173
environment(

distribution/packages/src/common/scripts/postinst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
# $1=0 : indicates a removal
99
# $1=1 : indicates an upgrade
1010

11+
# source the default env file
12+
if [ -f "${path.env}" ]; then
13+
. "${path.env}"
14+
else
15+
ES_PATH_CONF="${path.conf}"
16+
fi
17+
1118
IS_UPGRADE=false
1219

1320
case "$1" in
@@ -95,11 +102,11 @@ fi
95102

96103
# the equivalent code for rpm is in posttrans
97104
if [ "$PACKAGE" = "deb" ]; then
98-
if [ ! -f /etc/elasticsearch/elasticsearch.keystore ]; then
105+
if [ ! -f "${ES_PATH_CONF}"/elasticsearch.keystore ]; then
99106
/usr/share/elasticsearch/bin/elasticsearch-keystore create
100-
chown root:elasticsearch /etc/elasticsearch/elasticsearch.keystore
101-
chmod 660 /etc/elasticsearch/elasticsearch.keystore
102-
md5sum /etc/elasticsearch/elasticsearch.keystore > /etc/elasticsearch/.elasticsearch.keystore.initial_md5sum
107+
chown root:elasticsearch "${ES_PATH_CONF}"/elasticsearch.keystore
108+
chmod 660 "${ES_PATH_CONF}"/elasticsearch.keystore
109+
md5sum "${ES_PATH_CONF}"/elasticsearch.keystore > "${ES_PATH_CONF}"/.elasticsearch.keystore.initial_md5sum
103110
else
104111
/usr/share/elasticsearch/bin/elasticsearch-keystore upgrade
105112
fi

distribution/packages/src/common/scripts/postrm

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88
# On RedHat,
99
# $1=0 : indicates a removal
1010
# $1=1 : indicates an upgrade
11+
12+
# source the default env file
13+
if [ -f "${path.env}" ]; then
14+
. "${path.env}"
15+
else
16+
ES_PATH_CONF="${path.conf}"
17+
fi
18+
1119
REMOVE_DIRS=false
1220
REMOVE_USER_AND_GROUP=false
1321

@@ -73,8 +81,8 @@ if [ "$REMOVE_DIRS" = "true" ]; then
7381
fi
7482

7583
# delete the conf directory if and only if empty
76-
if [ -d /etc/elasticsearch ]; then
77-
rmdir --ignore-fail-on-non-empty /etc/elasticsearch
84+
if [ -d "${ES_PATH_CONF}" ]; then
85+
rmdir --ignore-fail-on-non-empty "${ES_PATH_CONF}"
7886
fi
7987

8088
fi

distribution/packages/src/common/scripts/prerm

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
# $1=0 : indicates a removal
1010
# $1=1 : indicates an upgrade
1111

12+
# source the default env file
13+
if [ -f "${path.env}" ]; then
14+
. "${path.env}"
15+
else
16+
ES_PATH_CONF="${path.conf}"
17+
fi
18+
1219
STOP_REQUIRED=false
1320
REMOVE_SERVICE=false
1421

@@ -65,9 +72,9 @@ if [ "$STOP_REQUIRED" = "true" ]; then
6572
echo " OK"
6673
fi
6774

68-
if [ -f /etc/elasticsearch/elasticsearch.keystore ]; then
69-
if md5sum --status -c /etc/elasticsearch/.elasticsearch.keystore.initial_md5sum; then
70-
rm /etc/elasticsearch/elasticsearch.keystore /etc/elasticsearch/.elasticsearch.keystore.initial_md5sum
75+
if [ -f "${ES_PATH_CONF}"/elasticsearch.keystore ]; then
76+
if md5sum --status -c "${ES_PATH_CONF}"/.elasticsearch.keystore.initial_md5sum; then
77+
rm "${ES_PATH_CONF}"/elasticsearch.keystore "${ES_PATH_CONF}"/.elasticsearch.keystore.initial_md5sum
7178
fi
7279
fi
7380

0 commit comments

Comments
 (0)