Skip to content

Commit 22d1df9

Browse files
committed
Merge branch '6.x' into ccr-6.x
* 6.x: 6d711fa (origin/6.x, 6.x) Uncouple persistent task state and status (#31031) f0f16b7 [TEST] Make SSL restrictions update atomic (#31050) 652193f Describe how to add a plugin in Dockerfile (#31340) bb568ab TEST: getCapturedRequestsAndClear should be atomic (#31312) 6f94914 Do not set vm.max_map_count when unnecessary (#31285) c12f3c7 Painless: Fix bug for static method calls on interfaces (#31348) 21128e2 QA: Fix resolution of default distribution (#31351) df17a83 Build: Fix the license in the pom zip and tar (#31336) 3e76b15 Treat ack timeout more like a publish timeout (#31303)
2 parents a4f5390 + 6d711fa commit 22d1df9

File tree

68 files changed

+759
-469
lines changed

Some content is hidden

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

68 files changed

+759
-469
lines changed

build.gradle

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,23 @@ subprojects {
4343
description = "Elasticsearch subproject ${project.path}"
4444
}
4545

46+
apply plugin: 'nebula.info-scm'
47+
String licenseCommit
48+
if (VersionProperties.elasticsearch.toString().endsWith('-SNAPSHOT')) {
49+
licenseCommit = scminfo.change ?: "master" // leniency for non git builds
50+
} else {
51+
licenseCommit = "v${version}"
52+
}
53+
String elasticLicenseUrl = "https://raw.githubusercontent.com/elastic/elasticsearch/${licenseCommit}/licenses/ELASTIC-LICENSE.txt"
54+
4655
subprojects {
56+
// Default to the apache license
4757
project.ext.licenseName = 'The Apache Software License, Version 2.0'
4858
project.ext.licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
59+
60+
// But stick the Elastic license url in project.ext so we can get it if we need to switch to it
61+
project.ext.elasticLicenseUrl = elasticLicenseUrl
62+
4963
// we only use maven publish to add tasks for pom generation
5064
plugins.withType(MavenPublishPlugin).whenPluginAdded {
5165
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);

0 commit comments

Comments
 (0)