Skip to content

Commit 6612d7f

Browse files
authored
Merge branch 'main' into search-response-builder
2 parents 673072e + ecda919 commit 6612d7f

File tree

93 files changed

+1041
-477
lines changed

Some content is hidden

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

93 files changed

+1041
-477
lines changed

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchJavaBasePlugin.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public class ElasticsearchJavaBasePlugin implements Plugin<Project> {
5858

5959
@Override
6060
public void apply(Project project) {
61-
project.getRootProject().getPlugins().apply(GlobalBuildInfoPlugin.class);
6261
// make sure the global build info plugin is applied to the root project
6362
project.getRootProject().getPluginManager().apply(GlobalBuildInfoPlugin.class);
6463
buildParams = project.getRootProject().getExtensions().getByType(BuildParameterExtension.class);

docs/changelog/121119.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

docs/changelog/121327.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 121327
2+
summary: Reduce Data Loss in System Indices Migration
3+
area: Infra/Core
4+
type: bug
5+
issues: []

docs/changelog/121821.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 121821
2+
summary: Fix get all inference endponts not returning multiple endpoints sharing model
3+
deployment
4+
area: Machine Learning
5+
type: bug
6+
issues: []

docs/changelog/122047.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

docs/changelog/122246.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 122246
2+
summary: Ensure removal of index blocks does not leave key with null value
3+
area: Data streams
4+
type: bug
5+
issues: []
1.58 KB
Binary file not shown.
1.5 KB
Binary file not shown.

libs/entitlement/asm-provider/src/main/java/org/elasticsearch/entitlement/instrumentation/impl/InstrumentationServiceImpl.java

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ public InstrumentationInfo lookupImplementationMethod(
118118
) throws NoSuchMethodException, ClassNotFoundException {
119119

120120
var targetMethod = targetSuperclass.getDeclaredMethod(methodName, parameterTypes);
121-
validateTargetMethod(implementationClass, targetMethod);
121+
var implementationMethod = implementationClass.getMethod(targetMethod.getName(), targetMethod.getParameterTypes());
122+
validateTargetMethod(implementationClass, targetMethod, implementationMethod);
122123

123124
var checkerAdditionalArguments = Stream.of(Class.class, targetSuperclass);
124125
var checkMethodArgumentTypes = Stream.concat(checkerAdditionalArguments, Arrays.stream(parameterTypes))
@@ -169,15 +170,15 @@ public MethodVisitor visitMethod(
169170

170171
return new InstrumentationInfo(
171172
new MethodKey(
172-
Type.getInternalName(implementationClass),
173-
targetMethod.getName(),
173+
Type.getInternalName(implementationMethod.getDeclaringClass()),
174+
implementationMethod.getName(),
174175
Arrays.stream(parameterTypes).map(c -> Type.getType(c).getInternalName()).toList()
175176
),
176177
checkMethod[0]
177178
);
178179
}
179180

180-
private static void validateTargetMethod(Class<?> implementationClass, Method targetMethod) {
181+
private static void validateTargetMethod(Class<?> implementationClass, Method targetMethod, Method implementationMethod) {
181182
if (targetMethod.getDeclaringClass().isAssignableFrom(implementationClass) == false) {
182183
throw new IllegalArgumentException(
183184
String.format(
@@ -209,37 +210,26 @@ private static void validateTargetMethod(Class<?> implementationClass, Method ta
209210
)
210211
);
211212
}
212-
try {
213-
var implementationMethod = implementationClass.getMethod(targetMethod.getName(), targetMethod.getParameterTypes());
214-
var methodModifiers = implementationMethod.getModifiers();
215-
if (Modifier.isAbstract(methodModifiers)) {
216-
throw new IllegalArgumentException(
217-
String.format(
218-
Locale.ROOT,
219-
"Not a valid instrumentation method: %s is abstract in %s",
220-
targetMethod.getName(),
221-
implementationClass.getName()
222-
)
223-
);
224-
}
225-
if (Modifier.isPublic(methodModifiers) == false) {
226-
throw new IllegalArgumentException(
227-
String.format(
228-
Locale.ROOT,
229-
"Not a valid instrumentation method: %s is not public in %s",
230-
targetMethod.getName(),
231-
implementationClass.getName()
232-
)
233-
);
234-
}
235-
} catch (NoSuchMethodException e) {
236-
assert false
237-
: String.format(
213+
var methodModifiers = implementationMethod.getModifiers();
214+
if (Modifier.isAbstract(methodModifiers)) {
215+
throw new IllegalArgumentException(
216+
String.format(
238217
Locale.ROOT,
239-
"Not a valid instrumentation method: %s cannot be found in %s",
218+
"Not a valid instrumentation method: %s is abstract in %s",
240219
targetMethod.getName(),
241220
implementationClass.getName()
242-
);
221+
)
222+
);
223+
}
224+
if (Modifier.isPublic(methodModifiers) == false) {
225+
throw new IllegalArgumentException(
226+
String.format(
227+
Locale.ROOT,
228+
"Not a valid instrumentation method: %s is not public in %s",
229+
targetMethod.getName(),
230+
implementationClass.getName()
231+
)
232+
);
243233
}
244234
}
245235

libs/entitlement/asm-provider/src/test/java/org/elasticsearch/entitlement/instrumentation/impl/InstrumentationServiceImplTests.java

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,16 @@ public void instanceMethod(int x, String y) {}
4040

4141
abstract static class TestTargetBaseClass {
4242
abstract void instanceMethod(int x, String y);
43+
44+
abstract void instanceMethod2(int x, String y);
4345
}
4446

45-
static class TestTargetImplementationClass extends TestTargetBaseClass {
47+
abstract static class TestTargetIntermediateClass extends TestTargetBaseClass {
48+
@Override
49+
public void instanceMethod2(int x, String y) {}
50+
}
51+
52+
static class TestTargetImplementationClass extends TestTargetIntermediateClass {
4653
@Override
4754
public void instanceMethod(int x, String y) {}
4855
}
@@ -364,6 +371,44 @@ public void testLookupImplementationMethodWithBaseClass() throws ClassNotFoundEx
364371
);
365372
}
366373

374+
public void testLookupImplementationMethodWithInheritance() throws ClassNotFoundException, NoSuchMethodException {
375+
var info = instrumentationService.lookupImplementationMethod(
376+
TestTargetBaseClass.class,
377+
"instanceMethod2",
378+
TestTargetImplementationClass.class,
379+
TestCheckerMixed.class,
380+
"checkInstanceMethodManual",
381+
int.class,
382+
String.class
383+
);
384+
385+
assertThat(
386+
info.targetMethod(),
387+
equalTo(
388+
new MethodKey(
389+
"org/elasticsearch/entitlement/instrumentation/impl/InstrumentationServiceImplTests$TestTargetIntermediateClass",
390+
"instanceMethod2",
391+
List.of("I", "java/lang/String")
392+
)
393+
)
394+
);
395+
assertThat(
396+
info.checkMethod(),
397+
equalTo(
398+
new CheckMethod(
399+
"org/elasticsearch/entitlement/instrumentation/impl/InstrumentationServiceImplTests$TestCheckerMixed",
400+
"checkInstanceMethodManual",
401+
List.of(
402+
"Ljava/lang/Class;",
403+
"Lorg/elasticsearch/entitlement/instrumentation/impl/InstrumentationServiceImplTests$TestTargetBaseClass;",
404+
"I",
405+
"Ljava/lang/String;"
406+
)
407+
)
408+
)
409+
);
410+
}
411+
367412
public void testParseCheckerMethodSignatureStaticMethod() {
368413
var methodKey = InstrumentationServiceImpl.parseCheckerMethodSignature(
369414
"check$org_example_TestClass$$staticMethod",

0 commit comments

Comments
 (0)