Skip to content

Commit 9c03b48

Browse files
committed
Merge branch 'master' into ccr
* master: 992c788 Uncouple persistent task state and status (#31031) 8c6ee7d Describe how to add a plugin in Dockerfile (#31340) 1c5cec0 Remove http status code maps (#31350) 87a676e Do not set vm.max_map_count when unnecessary (#31285) e5b7137 TEST: getCapturedRequestsAndClear should be atomic (#31312) 0324103 Painless: Fix bug for static method calls on interfaces (#31348) d6d0727 QA: Fix resolution of default distribution (#31351) fcf1e41 Extract common http logic to server (#31311) 6dd81ea Build: Fix the license in the pom zip and tar (#31336) 8f886cd Treat ack timeout more like a publish timeout (#31303) 9b29327 [ML] Add description to ML filters (#31330) f7a0caf SQL: Fix build on Java 10 375d09c [TEST] Fix RemoteClusterClientTests#testEnsureWeReconnect 4877cec More detailed tracing when writing metadata (#31319) bbfe1ec [Tests] Mutualize fixtures code in BaseHttpFixture (#31210)
2 parents cc824eb + 992c788 commit 9c03b48

File tree

150 files changed

+4459
-4872
lines changed

Some content is hidden

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

150 files changed

+4459
-4872
lines changed

build.gradle

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,23 @@ subprojects {
5353
description = "Elasticsearch subproject ${project.path}"
5454
}
5555

56+
apply plugin: 'nebula.info-scm'
57+
String licenseCommit
58+
if (VersionProperties.elasticsearch.toString().endsWith('-SNAPSHOT')) {
59+
licenseCommit = scminfo.change ?: "master" // leniency for non git builds
60+
} else {
61+
licenseCommit = "v${version}"
62+
}
63+
String elasticLicenseUrl = "https://raw.githubusercontent.com/elastic/elasticsearch/${licenseCommit}/licenses/ELASTIC-LICENSE.txt"
64+
5665
subprojects {
66+
// Default to the apache license
5767
project.ext.licenseName = 'The Apache Software License, Version 2.0'
5868
project.ext.licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
69+
70+
// But stick the Elastic license url in project.ext so we can get it if we need to switch to it
71+
project.ext.elasticLicenseUrl = elasticLicenseUrl
72+
5973
// we only use maven publish to add tasks for pom generation
6074
plugins.withType(MavenPublishPlugin).whenPluginAdded {
6175
publishing {

distribution/archives/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ subprojects {
228228
check.dependsOn checkNotice
229229

230230
if (project.name == 'zip' || project.name == 'tar') {
231+
project.ext.licenseName = 'Elastic License'
232+
project.ext.licenseUrl = ext.elasticLicenseUrl
231233
task checkMlCppNotice {
232234
dependsOn buildDist, checkExtraction
233235
onlyIf toolExists

distribution/packages/src/deb/init.d/elasticsearch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ case "$1" in
122122
ulimit -l $MAX_LOCKED_MEMORY
123123
fi
124124

125-
if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count ]; then
125+
if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count -a "$MAX_MAP_COUNT" -ge $(cat /proc/sys/vm/max_map_count) ]; then
126126
sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT
127127
fi
128128

distribution/packages/src/rpm/init.d/elasticsearch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ start() {
9090
if [ -n "$MAX_LOCKED_MEMORY" ]; then
9191
ulimit -l $MAX_LOCKED_MEMORY
9292
fi
93-
if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count ]; then
93+
if [ -n "$MAX_MAP_COUNT" -a -f /proc/sys/vm/max_map_count -a "$MAX_MAP_COUNT" -ge $(cat /proc/sys/vm/max_map_count) ]; then
9494
sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT
9595
fi
9696

docs/reference/setup/install/docker.asciidoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,13 @@ docker build --tag=elasticsearch-custom .
279279
docker run -ti -v /usr/share/elasticsearch/data elasticsearch-custom
280280
--------------------------------------------
281281

282+
Some plugins require additional security permissions. You have to explicitly accept
283+
them either by attaching a `tty` when you run the Docker image and accepting yes at
284+
the prompts, or inspecting the security permissions separately and if you are
285+
comfortable with them adding the `--batch` flag to the plugin install command.
286+
See {plugins}/_other_command_line_parameters.html[Plugin Management documentation]
287+
for more details.
288+
282289
===== D. Override the image's default https://docs.docker.com/engine/reference/run/#cmd-default-command-or-options[CMD]
283290

284291
Options can be passed as command-line options to the {es} process by

modules/lang-painless/src/main/java/org/elasticsearch/painless/Def.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,8 @@ private static MethodHandle lookupReferenceInternal(Definition definition, Looku
376376
ref.delegateClassName,
377377
ref.delegateInvokeType,
378378
ref.delegateMethodName,
379-
ref.delegateMethodType
379+
ref.delegateMethodType,
380+
ref.isDelegateInterface ? 1 : 0
380381
);
381382
return callSite.dynamicInvoker().asType(MethodType.methodType(clazz.clazz, captures));
382383
}

modules/lang-painless/src/main/java/org/elasticsearch/painless/Definition.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.elasticsearch.painless;
2121

2222
import org.elasticsearch.painless.spi.Whitelist;
23+
import org.objectweb.asm.Opcodes;
2324

2425
import java.lang.invoke.MethodHandle;
2526
import java.lang.invoke.MethodHandles;
@@ -202,16 +203,28 @@ public MethodType getMethodType() {
202203

203204
public void write(MethodWriter writer) {
204205
final org.objectweb.asm.Type type;
206+
final Class<?> clazz;
205207
if (augmentation != null) {
206208
assert java.lang.reflect.Modifier.isStatic(modifiers);
209+
clazz = augmentation;
207210
type = org.objectweb.asm.Type.getType(augmentation);
208211
} else {
212+
clazz = owner.clazz;
209213
type = owner.type;
210214
}
211215

212216
if (java.lang.reflect.Modifier.isStatic(modifiers)) {
213-
writer.invokeStatic(type, method);
214-
} else if (java.lang.reflect.Modifier.isInterface(owner.clazz.getModifiers())) {
217+
// invokeStatic assumes that the owner class is not an interface, so this is a
218+
// special case for interfaces where the interface method boolean needs to be set to
219+
// true to reference the appropriate class constant when calling a static interface
220+
// method since java 8 did not check, but java 9 and 10 do
221+
if (java.lang.reflect.Modifier.isInterface(clazz.getModifiers())) {
222+
writer.visitMethodInsn(Opcodes.INVOKESTATIC,
223+
type.getInternalName(), name, getMethodType().toMethodDescriptorString(), true);
224+
} else {
225+
writer.invokeStatic(type, method);
226+
}
227+
} else if (java.lang.reflect.Modifier.isInterface(clazz.getModifiers())) {
215228
writer.invokeInterface(type, method);
216229
} else {
217230
writer.invokeVirtual(type, method);

modules/lang-painless/src/main/java/org/elasticsearch/painless/FunctionRef.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ public class FunctionRef {
6666
/** delegate method type method as type */
6767
public final Type delegateType;
6868

69+
/** whether a call is made on a delegate interface */
70+
public final boolean isDelegateInterface;
71+
6972
/**
7073
* Creates a new FunctionRef, which will resolve {@code type::call} from the whitelist.
7174
* @param definition the whitelist against which this script is being compiled
@@ -97,10 +100,13 @@ public FunctionRef(Class<?> expected, Method interfaceMethod, Method delegateMet
97100
// the Painless$Script class can be inferred if owner is null
98101
if (delegateMethod.owner == null) {
99102
delegateClassName = CLASS_NAME;
103+
isDelegateInterface = false;
100104
} else if (delegateMethod.augmentation != null) {
101105
delegateClassName = delegateMethod.augmentation.getName();
106+
isDelegateInterface = delegateMethod.augmentation.isInterface();
102107
} else {
103108
delegateClassName = delegateMethod.owner.clazz.getName();
109+
isDelegateInterface = delegateMethod.owner.clazz.isInterface();
104110
}
105111

106112
if ("<init>".equals(delegateMethod.name)) {
@@ -139,6 +145,7 @@ public FunctionRef(Class<?> expected,
139145
delegateInvokeType = H_INVOKESTATIC;
140146
this.delegateMethodName = delegateMethodName;
141147
this.delegateMethodType = delegateMethodType.dropParameterTypes(0, numCaptures);
148+
isDelegateInterface = false;
142149

143150
this.interfaceMethod = null;
144151
delegateMethod = null;

modules/lang-painless/src/main/java/org/elasticsearch/painless/LambdaBootstrap.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ private Capture(int count, Class<?> type) {
188188
* @param delegateMethodName The name of the method to be called in the Painless script class
189189
* @param delegateMethodType The type of method call in the Painless script class without
190190
* the captured types
191+
* @param isDelegateInterface If the method to be called is owned by an interface where
192+
* if the value is '1' if the delegate is an interface and '0'
193+
* otherwise; note this is an int because the bootstrap method
194+
* cannot convert constants to boolean
191195
* @return A {@link CallSite} linked to a factory method for creating a lambda class
192196
* that implements the expected functional interface
193197
* @throws LambdaConversionException Thrown when an illegal type conversion occurs at link time
@@ -200,7 +204,8 @@ public static CallSite lambdaBootstrap(
200204
String delegateClassName,
201205
int delegateInvokeType,
202206
String delegateMethodName,
203-
MethodType delegateMethodType)
207+
MethodType delegateMethodType,
208+
int isDelegateInterface)
204209
throws LambdaConversionException {
205210
Loader loader = (Loader)lookup.lookupClass().getClassLoader();
206211
String lambdaClassName = Type.getInternalName(lookup.lookupClass()) + "$$Lambda" + loader.newLambdaIdentifier();
@@ -225,7 +230,7 @@ public static CallSite lambdaBootstrap(
225230

226231
generateInterfaceMethod(cw, factoryMethodType, lambdaClassType, interfaceMethodName,
227232
interfaceMethodType, delegateClassType, delegateInvokeType,
228-
delegateMethodName, delegateMethodType, captures);
233+
delegateMethodName, delegateMethodType, isDelegateInterface == 1, captures);
229234

230235
endLambdaClass(cw);
231236

@@ -369,6 +374,7 @@ private static void generateInterfaceMethod(
369374
int delegateInvokeType,
370375
String delegateMethodName,
371376
MethodType delegateMethodType,
377+
boolean isDelegateInterface,
372378
Capture[] captures)
373379
throws LambdaConversionException {
374380

@@ -434,7 +440,7 @@ private static void generateInterfaceMethod(
434440
Handle delegateHandle =
435441
new Handle(delegateInvokeType, delegateClassType.getInternalName(),
436442
delegateMethodName, delegateMethodType.toMethodDescriptorString(),
437-
delegateInvokeType == H_INVOKEINTERFACE);
443+
isDelegateInterface);
438444
iface.invokeDynamic(delegateMethodName, Type.getMethodType(interfaceMethodType
439445
.toMethodDescriptorString()).getDescriptor(), DELEGATE_BOOTSTRAP_HANDLE,
440446
delegateHandle);

modules/lang-painless/src/main/java/org/elasticsearch/painless/WriterConstants.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ public final class WriterConstants {
141141

142142
/** invokedynamic bootstrap for lambda expression/method references */
143143
public static final MethodType LAMBDA_BOOTSTRAP_TYPE =
144-
MethodType.methodType(CallSite.class, MethodHandles.Lookup.class, String.class,
145-
MethodType.class, MethodType.class, String.class, int.class, String.class, MethodType.class);
144+
MethodType.methodType(CallSite.class, MethodHandles.Lookup.class, String.class, MethodType.class,
145+
MethodType.class, String.class, int.class, String.class, MethodType.class, int.class);
146146
public static final Handle LAMBDA_BOOTSTRAP_HANDLE =
147147
new Handle(Opcodes.H_INVOKESTATIC, Type.getInternalName(LambdaBootstrap.class),
148148
"lambdaBootstrap", LAMBDA_BOOTSTRAP_TYPE.toMethodDescriptorString(), false);

modules/lang-painless/src/main/java/org/elasticsearch/painless/node/ECapturingFunctionRef.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ void write(MethodWriter writer, Globals globals) {
121121
ref.delegateClassName,
122122
ref.delegateInvokeType,
123123
ref.delegateMethodName,
124-
ref.delegateType
124+
ref.delegateType,
125+
ref.isDelegateInterface ? 1 : 0
125126
);
126127
}
127128
}

modules/lang-painless/src/main/java/org/elasticsearch/painless/node/EFunctionRef.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ void write(MethodWriter writer, Globals globals) {
112112
ref.delegateClassName,
113113
ref.delegateInvokeType,
114114
ref.delegateMethodName,
115-
ref.delegateType
115+
ref.delegateType,
116+
ref.isDelegateInterface ? 1 : 0
116117
);
117118
} else {
118119
// TODO: don't do this: its just to cutover :)

modules/lang-painless/src/main/java/org/elasticsearch/painless/node/ELambda.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ void write(MethodWriter writer, Globals globals) {
222222
ref.delegateClassName,
223223
ref.delegateInvokeType,
224224
ref.delegateMethodName,
225-
ref.delegateType
225+
ref.delegateType,
226+
ref.isDelegateInterface ? 1 : 0
226227
);
227228
} else {
228229
// placeholder

modules/lang-painless/src/test/java/org/elasticsearch/painless/BasicExpressionTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,11 @@ public void testNullSafeDeref() {
264264
// assertEquals(null, exec("def a = ['thing': 'bar']; a.other?.cat?.dog = 'wombat'; return a.other?.cat?.dog"));
265265
}
266266

267+
// test to ensure static interface methods are called correctly
268+
public void testStaticInterfaceMethod() {
269+
assertEquals(4, exec("def values = [1, 4, 3, 2]; values.sort(Comparator.comparing(p -> p)); return values[3]"));
270+
}
271+
267272
private void assertMustBeNullable(String script) {
268273
Exception e = expectScriptThrows(IllegalArgumentException.class, false, () -> exec(script));
269274
assertEquals("Result of null safe operator must be nullable", e.getMessage());

modules/lang-painless/src/test/java/org/elasticsearch/painless/FunctionRefTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,11 @@ public void testInterfaceDefaultMethodDef() {
184184
"def map = new HashMap(); f(map::getOrDefault)"));
185185
}
186186

187+
public void testInterfaceStaticMethod() {
188+
assertEquals(-1, exec("Supplier get(Supplier supplier) { return supplier }" +
189+
"Supplier s = get(Comparator::naturalOrder); s.get().compare(1, 2)"));
190+
}
191+
187192
public void testMethodMissing() {
188193
Exception e = expectScriptThrows(IllegalArgumentException.class, () -> {
189194
exec("List l = [2, 1]; l.sort(Integer::bogus); return l.get(0);");

modules/repository-url/build.gradle

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ esplugin {
2323
classname 'org.elasticsearch.plugin.repository.url.URLRepositoryPlugin'
2424
}
2525

26-
forbiddenApisTest {
27-
// we are using jdk-internal instead of jdk-non-portable to allow for com.sun.net.httpserver.* usage
28-
bundledSignatures -= 'jdk-non-portable'
29-
bundledSignatures += 'jdk-internal'
30-
}
31-
3226
// This directory is shared between two URL repositories and one FS repository in YAML integration tests
3327
File repositoryDir = new File(project.buildDir, "shared-repository")
3428

0 commit comments

Comments
 (0)