Upgrade spotless plugin to 6.17.0 (#94994)

Fixes #82794. Upgrade the spotless plugin, which addresses the issue
around formatting `instanceof` expressions. Formatting of statements
including lambdas seems to have improved too.
This commit is contained in:
Rory Hunter 2023-04-04 10:03:32 +01:00 committed by GitHub
parent 696e63570f
commit fe1083f6c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
349 changed files with 2104 additions and 2716 deletions

View file

@ -60,7 +60,9 @@ public class MapperServiceFactory {
.withDeprecationHandler(LoggingDeprecationHandler.INSTANCE),
similarityService,
mapperRegistry,
() -> { throw new UnsupportedOperationException(); },
() -> {
throw new UnsupportedOperationException();
},
new ProvidedIdFieldMapper(() -> true),
new ScriptCompiler() {
@Override

View file

@ -175,7 +175,9 @@ public class QueryParserHelperBenchmark {
.withDeprecationHandler(LoggingDeprecationHandler.INSTANCE),
similarityService,
mapperRegistry,
() -> { throw new UnsupportedOperationException(); },
() -> {
throw new UnsupportedOperationException();
},
new ProvidedIdFieldMapper(() -> true),
new ScriptCompiler() {
@Override

View file

@ -406,50 +406,50 @@ public class DistanceFunctionBenchmark {
case "float" -> {
switch (function) {
case "dot" -> benchmarkFunction = switch (type) {
case "knn" -> new DotKnnFloatBenchmarkFunction(dims);
case "binary" -> new DotBinaryFloatBenchmarkFunction(dims);
default -> throw new UnsupportedOperationException("unexpected type [" + type + "]");
};
case "knn" -> new DotKnnFloatBenchmarkFunction(dims);
case "binary" -> new DotBinaryFloatBenchmarkFunction(dims);
default -> throw new UnsupportedOperationException("unexpected type [" + type + "]");
};
case "cosine" -> benchmarkFunction = switch (type) {
case "knn" -> new CosineKnnFloatBenchmarkFunction(dims);
case "binary" -> new CosineBinaryFloatBenchmarkFunction(dims);
default -> throw new UnsupportedOperationException("unexpected type [" + type + "]");
};
case "knn" -> new CosineKnnFloatBenchmarkFunction(dims);
case "binary" -> new CosineBinaryFloatBenchmarkFunction(dims);
default -> throw new UnsupportedOperationException("unexpected type [" + type + "]");
};
case "l1" -> benchmarkFunction = switch (type) {
case "knn" -> new L1KnnFloatBenchmarkFunction(dims);
case "binary" -> new L1BinaryFloatBenchmarkFunction(dims);
default -> throw new UnsupportedOperationException("unexpected type [" + type + "]");
};
case "knn" -> new L1KnnFloatBenchmarkFunction(dims);
case "binary" -> new L1BinaryFloatBenchmarkFunction(dims);
default -> throw new UnsupportedOperationException("unexpected type [" + type + "]");
};
case "l2" -> benchmarkFunction = switch (type) {
case "knn" -> new L2KnnFloatBenchmarkFunction(dims);
case "binary" -> new L2BinaryFloatBenchmarkFunction(dims);
default -> throw new UnsupportedOperationException("unexpected type [" + type + "]");
};
case "knn" -> new L2KnnFloatBenchmarkFunction(dims);
case "binary" -> new L2BinaryFloatBenchmarkFunction(dims);
default -> throw new UnsupportedOperationException("unexpected type [" + type + "]");
};
default -> throw new UnsupportedOperationException("unexpected function [" + function + "]");
}
}
case "byte" -> {
switch (function) {
case "dot" -> benchmarkFunction = switch (type) {
case "knn" -> new DotKnnByteBenchmarkFunction(dims);
case "binary" -> new DotBinaryByteBenchmarkFunction(dims);
default -> throw new UnsupportedOperationException("unexpected type [" + type + "]");
};
case "knn" -> new DotKnnByteBenchmarkFunction(dims);
case "binary" -> new DotBinaryByteBenchmarkFunction(dims);
default -> throw new UnsupportedOperationException("unexpected type [" + type + "]");
};
case "cosine" -> benchmarkFunction = switch (type) {
case "knn" -> new CosineKnnByteBenchmarkFunction(dims);
case "binary" -> new CosineBinaryByteBenchmarkFunction(dims);
default -> throw new UnsupportedOperationException("unexpected type [" + type + "]");
};
case "knn" -> new CosineKnnByteBenchmarkFunction(dims);
case "binary" -> new CosineBinaryByteBenchmarkFunction(dims);
default -> throw new UnsupportedOperationException("unexpected type [" + type + "]");
};
case "l1" -> benchmarkFunction = switch (type) {
case "knn" -> new L1KnnByteBenchmarkFunction(dims);
case "binary" -> new L1BinaryByteBenchmarkFunction(dims);
default -> throw new UnsupportedOperationException("unexpected type [" + type + "]");
};
case "knn" -> new L1KnnByteBenchmarkFunction(dims);
case "binary" -> new L1BinaryByteBenchmarkFunction(dims);
default -> throw new UnsupportedOperationException("unexpected type [" + type + "]");
};
case "l2" -> benchmarkFunction = switch (type) {
case "knn" -> new L2KnnByteBenchmarkFunction(dims);
case "binary" -> new L2BinaryByteBenchmarkFunction(dims);
default -> throw new UnsupportedOperationException("unexpected type [" + type + "]");
};
case "knn" -> new L2KnnByteBenchmarkFunction(dims);
case "binary" -> new L2BinaryByteBenchmarkFunction(dims);
default -> throw new UnsupportedOperationException("unexpected type [" + type + "]");
};
default -> throw new UnsupportedOperationException("unexpected function [" + function + "]");
}
}

View file

@ -133,7 +133,7 @@ public class ElasticsearchJavaModulePathPlugin implements Plugin<Project> {
return false;
}
return isModuleDependency
|| (it.getId()instanceof ProjectComponentIdentifier projectId && hasModuleInfoDotJava(project, projectId));
|| (it.getId() instanceof ProjectComponentIdentifier projectId && hasModuleInfoDotJava(project, projectId));
})
.flatMap(it -> Stream.concat(walkResolvedComponent(project, it, true, visited), Stream.of(it.getId())));
}

View file

@ -54,12 +54,9 @@ public class InternalDistributionBwcSetupPlugin implements Plugin<Project> {
@Override
public void apply(Project project) {
project.getRootProject().getPluginManager().apply(GlobalBuildInfoPlugin.class);
BuildParams.getBwcVersions()
.forPreviousUnreleased(
(BwcVersions.UnreleasedVersionInfo unreleasedVersion) -> {
configureBwcProject(project.project(unreleasedVersion.gradleProjectPath()), unreleasedVersion);
}
);
BuildParams.getBwcVersions().forPreviousUnreleased((BwcVersions.UnreleasedVersionInfo unreleasedVersion) -> {
configureBwcProject(project.project(unreleasedVersion.gradleProjectPath()), unreleasedVersion);
});
}
private void configureBwcProject(Project project, BwcVersions.UnreleasedVersionInfo versionInfo) {

View file

@ -32,13 +32,9 @@ public class DockerSupportPlugin implements Plugin<Project> {
Provider<DockerSupportService> dockerSupportServiceProvider = project.getGradle()
.getSharedServices()
.registerIfAbsent(
DOCKER_SUPPORT_SERVICE_NAME,
DockerSupportService.class,
spec -> spec.parameters(
params -> { params.setExclusionsFile(new File(project.getRootDir(), DOCKER_ON_LINUX_EXCLUSIONS_FILE)); }
)
);
.registerIfAbsent(DOCKER_SUPPORT_SERVICE_NAME, DockerSupportService.class, spec -> spec.parameters(params -> {
params.setExclusionsFile(new File(project.getRootDir(), DOCKER_ON_LINUX_EXCLUSIONS_FILE));
}));
// Ensure that if we are trying to run any DockerBuildTask tasks, we assert an available Docker installation exists
project.getGradle().getTaskGraph().whenReady(graph -> {

View file

@ -199,13 +199,9 @@ public class DistroTestPlugin implements Plugin<Project> {
// windows boxes get windows distributions, and linux boxes get linux distributions
if (isWindows(vmProject)) {
configureVMWrapperTasks(
vmProject,
windowsTestTasks,
depsTasks,
wrapperTask -> { vmLifecyleTasks.get(ARCHIVE).configure(t -> t.dependsOn(wrapperTask)); },
vmDependencies
);
configureVMWrapperTasks(vmProject, windowsTestTasks, depsTasks, wrapperTask -> {
vmLifecyleTasks.get(ARCHIVE).configure(t -> t.dependsOn(wrapperTask));
}, vmDependencies);
} else {
for (var entry : linuxTestTasks.entrySet()) {
ElasticsearchDistributionType type = entry.getKey();

View file

@ -130,8 +130,9 @@ public class RestTestTransformer {
}
}
}
currentNode.elements()
.forEachRemaining(node -> { traverseTest(testContext, node, parentKeyName, objectKeyFinders, arrayByObjectKeyFinders); });
currentNode.elements().forEachRemaining(node -> {
traverseTest(testContext, node, parentKeyName, objectKeyFinders, arrayByObjectKeyFinders);
});
} else if (currentNode.isObject()) {
currentNode.fields().forEachRemaining(entry -> {
List<RestTestTransformByParentObject> transforms = objectKeyFinders.get(entry.getKey());

View file

@ -1372,7 +1372,7 @@ public class ElasticsearchNode implements TestClusterConfiguration {
}
});
} catch (UncheckedIOException e) {
if (e.getCause()instanceof NoSuchFileException cause) {
if (e.getCause() instanceof NoSuchFileException cause) {
// Ignore these files that are sometimes left behind by the JVM
if (cause.getFile() == null || cause.getFile().contains(".attach_pid") == false) {
throw new UncheckedIOException(cause);

View file

@ -8,7 +8,7 @@
package org.elasticsearch.gradle.util;
public record Pair<L, R> (L left, R right) {
public record Pair<L, R>(L left, R right) {
public static <L, R> Pair<L, R> of(L left, R right) {
return new Pair<>(left, right);

View file

@ -19,7 +19,9 @@ public class MainResponse {
private static final ConstructingObjectParser<MainResponse, Void> PARSER = new ConstructingObjectParser<>(
MainResponse.class.getName(),
true,
args -> { return new MainResponse((String) args[0], (Version) args[1], (String) args[2], (String) args[3], (String) args[4]); }
args -> {
return new MainResponse((String) args[0], (Version) args[1], (String) args[2], (String) args[3], (String) args[4]);
}
);
static {

View file

@ -143,24 +143,24 @@ public class NodeRestUsageIT extends ESRestTestCase {
// Do some requests to get some rest usage stats
Request create = new Request("PUT", "/test");
create.setJsonEntity("""
{
"mappings": {
"properties": {
"str": {
"type": "keyword"
},
"foo": {
"type": "keyword"
},
"num": {
"type": "long"
},
"start": {
"type": "date"
}
}
{
"mappings": {
"properties": {
"str": {
"type": "keyword"
},
"foo": {
"type": "keyword"
},
"num": {
"type": "long"
},
"start": {
"type": "date"
}
}""");
}
}
}""");
client().performRequest(create);
Request searchRequest = new Request("GET", "/test/_search");

View file

@ -39,6 +39,6 @@ shadow-plugin = "gradle.plugin.com.github.johnrengelman:shadow:7.1.2"
spock-core = { group = "org.spockframework", name="spock-core", version.ref="spock" }
spock-junit4 = { group = "org.spockframework", name="spock-junit4", version.ref="spock" }
spock-platform = { group = "org.spockframework", name="spock-bom", version.ref="spock" }
spotless-plugin = "com.diffplug.spotless:spotless-plugin-gradle:6.11.0"
spotless-plugin = "com.diffplug.spotless:spotless-plugin-gradle:6.17.0"
wiremock = "com.github.tomakehurst:wiremock-jre8-standalone:2.23.2"
xmlunit-core = "org.xmlunit:xmlunit-core:2.8.2"

View file

@ -179,6 +179,11 @@
<sha256 value="095fd1dc77888c073f0be39a018156ee526722798b09de9e285ef2135e16eac4" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.diffplug.durian" name="durian-swt.os" version="4.1.1">
<artifact name="durian-swt.os-4.1.1.jar">
<sha256 value="9ff15ac4f14c4ef9e241108392c43347916a433658c5ad971e999df1191b3230" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.diffplug.spotless" name="spotless-eclipse-base" version="3.5.2">
<artifact name="spotless-eclipse-base-3.5.2.jar">
<sha256 value="e381d6996a3d7f41c02d79bd0b1dff077aaec40b55fa15971c1bb45ab16f5a20" origin="Generated by Gradle"/>
@ -194,16 +199,31 @@
<sha256 value="21f4d7fc032bfada42f29e629ce7d894e1a9bcf7dd5aa9b243fedd0c7d24f0a1" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.diffplug.spotless" name="spotless-lib" version="2.37.0">
<artifact name="spotless-lib-2.37.0.jar">
<sha256 value="71ffe1c3c3511ab44454ead09c20b9203cc3a14493453a18d1d8df862659c9fb" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.diffplug.spotless" name="spotless-lib-extra" version="2.30.0">
<artifact name="spotless-lib-extra-2.30.0.jar">
<sha256 value="9b4ce98aa4f5dbc75850fe6d9a79e878d318be718f997e5ea4052c885621baab" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.diffplug.spotless" name="spotless-lib-extra" version="2.37.0">
<artifact name="spotless-lib-extra-2.37.0.jar">
<sha256 value="9bc857d39085731c1fa2db883c69ad8bdaa104482816f4a56798a124fe60c1f8" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.diffplug.spotless" name="spotless-plugin-gradle" version="6.11.0">
<artifact name="spotless-plugin-gradle-6.11.0.jar">
<sha256 value="54293b86170b821115772090bb90aeb466cda6bf9e08b06bacbd3bb94a714e1f" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.diffplug.spotless" name="spotless-plugin-gradle" version="6.17.0">
<artifact name="spotless-plugin-gradle-6.17.0.jar">
<sha256 value="8f27c05d31a4389259ba54938c476427ae8a88cc1540d421623fdc6c9fc86f7b" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.ethlo.time" name="itu" version="1.7.0">
<artifact name="itu-1.7.0.jar">
<sha256 value="55ceb418c9e8138c4fcf62e213c4c814d89e8a84c827d395407cbecba5d791e7" origin="Generated by Gradle"/>
@ -789,6 +809,11 @@
<sha256 value="88ac9fd1bb51f82bcc664cc1eb9c225c90dc4389d660231b4cc737bebfe7d0aa" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.squareup.okhttp3" name="okhttp" version="4.10.0">
<artifact name="okhttp-4.10.0.jar">
<sha256 value="7580f14fa1691206e37081ad3f92063b1603b328da0bb316f2fef02e0562e7ec" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.squareup.okio" name="okio" version="1.4.0">
<artifact name="okio-1.4.0.jar">
<sha256 value="b53c1760864e1c39b5275d9023e2a6fbe8f3189e6e67b4c87877b8ec8f92e05a" origin="Generated by Gradle"/>
@ -799,6 +824,11 @@
<sha256 value="114bdc1f47338a68bcbc95abf2f5cdc72beeec91812f2fcd7b521c1937876266" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.squareup.okio" name="okio-jvm" version="3.0.0">
<artifact name="okio-jvm-3.0.0.jar">
<sha256 value="be64a0cc1f28ea9cd5c970dd7e7557af72c808d738c495b397bf897c9921e907" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.sun.activation" name="jakarta.activation" version="1.2.1">
<artifact name="jakarta.activation-1.2.1.jar">
<sha256 value="d84d4ba8b55cdb7fdcbb885e6939386367433f56f5ab8cfdc302a7c3587fa92b" origin="Generated by Gradle"/>
@ -1054,6 +1084,11 @@
<sha256 value="c02730010ecc60ed49fb23e5ec25f678789a2c1a2582835806bc0ae6100ee109" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="dev.equo.ide" name="solstice" version="1.0.0">
<artifact name="solstice-1.0.0.jar">
<sha256 value="0ce1317572fb65b6045ffde5c4ccf104dd42552dda0fd1621120b92c1c4df16d" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="dnsjava" name="dnsjava" version="2.1.7">
<artifact name="dnsjava-2.1.7.jar">
<sha256 value="2c52a6fabd5af9331d73fc7787dafc32a56bd8019c49f89749c2eeef244e303c" origin="Generated by Gradle"/>
@ -1883,6 +1918,11 @@
<sha256 value="f2354b8207926be80debb9edd3108cd0b86eff8e4fe22a9244f214723f96d28e" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.apache.felix" name="org.apache.felix.scr" version="2.2.4">
<artifact name="org.apache.felix.scr-2.2.4.jar">
<sha256 value="f4a14dc142faee676c81757104469895caf0b858c9326416b8246da6abaadd89" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.apache.geronimo.specs" name="geronimo-jcache_1.0_spec" version="1.0-alpha-1">
<artifact name="geronimo-jcache_1.0_spec-1.0-alpha-1.jar">
<sha256 value="0070a12e58f491b95719391325299a6294530ee6c3ce25e50bdc98b0b700966c" origin="Generated by Gradle"/>
@ -3204,6 +3244,11 @@
<sha256 value="c84bba71adf3a11db1d2a93dbe2e056eba2e5418f04a437540a7946c24db20c8" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.jdt" name="org.eclipse.jdt.core" version="3.32.0">
<artifact name="org.eclipse.jdt.core-3.32.0.jar">
<sha256 value="cd396e4368b025f8f898ea7b7693fe5b9b1f6981c365c3857420d178132ef945" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.jetty" name="jetty-annotations" version="9.4.40.v20210413">
<artifact name="jetty-annotations-9.4.40.v20210413.jar">
<sha256 value="faccdc2113daf5ace9157cacd98751a41280fec94f584fd571b7fc26ff84742d" origin="Generated by Gradle"/>
@ -3309,46 +3354,106 @@
<sha256 value="d679365a6c8e55c1496701099f5e5765433f68dcb659759416ba5b222eb5055c" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.jgit" name="org.eclipse.jgit" version="6.5.0.202303070854-r">
<artifact name="org.eclipse.jgit-6.5.0.202303070854-r.jar">
<sha256 value="9b4da8cde1651fa7a9f4d242585fe94343d40165e4c06ad5a722044a2cbe6251" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.core.commands" version="3.10.100">
<artifact name="org.eclipse.core.commands-3.10.100.jar">
<sha256 value="177c605efd78681e28765b869a2ff5284a79b02d133007a6169a64317cee8633" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.core.commands" version="3.10.300">
<artifact name="org.eclipse.core.commands-3.10.300.jar">
<sha256 value="e589b4036723278bcd25e7aa190d1632a58569437a202d5c2b97c7ac9847b874" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.core.contenttype" version="3.8.0">
<artifact name="org.eclipse.core.contenttype-3.8.0.jar">
<sha256 value="f90fa8dd89b9da7d5e817281f963b46ad1414d33376354e541464434f0b23c90" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.core.contenttype" version="3.8.200">
<artifact name="org.eclipse.core.contenttype-3.8.200.jar">
<sha256 value="d32716bfb03e7f3244a5df0f8816a8f0b6644a8c782f54062af8a3b00e1b4e45" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.core.expressions" version="3.8.200">
<artifact name="org.eclipse.core.expressions-3.8.200.jar">
<sha256 value="13dbbe3256f1199c69a79c3ba4c6ee79e6c1a0e73f67d49f5f3365b7ad387818" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.core.filesystem" version="1.9.100">
<artifact name="org.eclipse.core.filesystem-1.9.100.jar">
<sha256 value="36e802c4d9a2c864e7d6b22b8d06f59927d113475ea04b3fd9bf6312d5a97ff6" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.core.filesystem" version="1.9.500">
<artifact name="org.eclipse.core.filesystem-1.9.500.jar">
<sha256 value="0c4810a1fa6e871c0bb23b29090a72c83b760af8171495c1325b4711b919072b" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.core.jobs" version="3.12.0">
<artifact name="org.eclipse.core.jobs-3.12.0.jar">
<sha256 value="98cc919c93c5a1c45e15afc82c64fc2b91a6b4c243bed6925ccdd4e3db3a96e9" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.core.jobs" version="3.13.200">
<artifact name="org.eclipse.core.jobs-3.13.200.jar">
<sha256 value="f6303d411f5013aac5e3491860392b7fddc09b518d0eb63722b0926679cd9dbf" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.core.resources" version="3.15.100">
<artifact name="org.eclipse.core.resources-3.15.100.jar">
<sha256 value="428cc4ac13e6d4992f9806d67ee2a80e35005ae3ccd08f1788ed1693a05d35fa" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.core.resources" version="3.18.100">
<artifact name="org.eclipse.core.resources-3.18.100.jar">
<sha256 value="4607aa2affc287783e498dc01a93d0338a549ffefb00df4b18aef8824622100a" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.core.runtime" version="3.23.0">
<artifact name="org.eclipse.core.runtime-3.23.0.jar">
<sha256 value="c81c0fd5c3cb632c93586c80f31461749f43104e3499f53e0cf33525bd606ce3" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.core.runtime" version="3.26.100">
<artifact name="org.eclipse.core.runtime-3.26.100.jar">
<sha256 value="f90ebd2f052d602281840b2b8cd1f5a7b6d1cf2d5a85b7b0415c70456855d173" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.equinox.app" version="1.6.0">
<artifact name="org.eclipse.equinox.app-1.6.0.jar">
<sha256 value="745332dac397b823a7e3e3348447339f8fdb1973ceea4851612978ccf80bcc8c" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.equinox.app" version="1.6.200">
<artifact name="org.eclipse.equinox.app-1.6.200.jar">
<sha256 value="52840b5fe48ed8f50a26d792d21b2db73b622a0a10d64c18883da6fb85dcbc24" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.equinox.common" version="3.15.0">
<artifact name="org.eclipse.equinox.common-3.15.0.jar">
<sha256 value="044a3d106f514072b1d0dd48638c1f8ffe93300a05d6943766992449ed9e0b3a" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.equinox.common" version="3.17.0">
<artifact name="org.eclipse.equinox.common-3.17.0.jar">
<sha256 value="e85fee16eba255a451cbed66c03dc024267542036bdc590f7b7a6b3092959ada" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.equinox.event" version="1.6.100">
<artifact name="org.eclipse.equinox.event-1.6.100.jar">
<sha256 value="72e27d45e88f47717a1d172cbd1236a7454ba74749b96bb204a3357956621229" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.equinox.preferences" version="3.10.100">
<artifact name="org.eclipse.equinox.preferences-3.10.100.jar">
<sha256 value="ee791bfa46e35e3551209b89b2152544a6f860a12c4aab4a2f6c9c0cc3dd1dda" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.equinox.preferences" version="3.9.0">
<artifact name="org.eclipse.equinox.preferences-3.9.0.jar">
<sha256 value="02da6934a2e02d23b9016ec4eb5234733eeafd1f938acc23368b0d30c3567ae9" origin="Generated by Gradle"/>
@ -3359,16 +3464,36 @@
<sha256 value="20a89fd326063e7ebe29308fa347a23b377924280038bc4233436d9117a8ba7b" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.equinox.registry" version="3.11.200">
<artifact name="org.eclipse.equinox.registry-3.11.200.jar">
<sha256 value="7a3668ca406930213e3edb8024ac72c51fbc3f289de63a33254c8070aa8d0a3f" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.equinox.supplement" version="1.10.600">
<artifact name="org.eclipse.equinox.supplement-1.10.600.jar">
<sha256 value="d36dd1d1b0db36a3dad7a7b7f2f93ca48140fc3e663b47b0d56aed5c5e6fd655" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.osgi" version="3.17.0">
<artifact name="org.eclipse.osgi-3.17.0.jar">
<sha256 value="b9b5cf6bb057b94be55f3510bdd831cdbaef16f2d1cab6b3770b72452811e538" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.osgi" version="3.18.200">
<artifact name="org.eclipse.osgi-3.18.200.jar">
<sha256 value="efa0779f1c0cdabb7fcbced2adbbf8632e1e8e239cb03ed9f37dd40c63a975d2" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.text" version="3.12.0">
<artifact name="org.eclipse.text-3.12.0.jar">
<sha256 value="457c1f8af07e870acce65130a2d9aa1e0fd95c92a7667bbd2db5bf7f9f19dd31" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.eclipse.platform" name="org.eclipse.text" version="3.12.300">
<artifact name="org.eclipse.text-3.12.300.jar">
<sha256 value="6c4f4f01397ae566cb7007ca885ffc5d1813c913d6602d78a8f81801a39060e8" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.ehcache" name="ehcache" version="3.3.1">
<artifact name="ehcache-3.3.1.jar">
<sha256 value="bb3bad2519b4fde456ca3c7f06a44235da347699fcf4cb29bc9f6a0cb09604f6" origin="Generated by Gradle"/>
@ -3444,21 +3569,41 @@
<sha256 value="f78c5d8c09db985912ab83a1de3c3b53ddf208d7b151f06a72358ea3e137d01b" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains.kotlin" name="kotlin-stdlib" version="1.6.20">
<artifact name="kotlin-stdlib-1.6.20.jar">
<sha256 value="eeb51c2b67b26233fd81d0bc4f8044ec849718890905763ceffd84a31e2cb799" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains.kotlin" name="kotlin-stdlib-common" version="1.4.21">
<artifact name="kotlin-stdlib-common-1.4.21.jar">
<sha256 value="812cf197d9c4c67e1f47f95e2d72a9b600f0d1124560617bfe9850773eccbcff" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains.kotlin" name="kotlin-stdlib-common" version="1.6.20">
<artifact name="kotlin-stdlib-common-1.6.20.jar">
<sha256 value="8da40a2520d30dcb1012176fe93d24e82d08a3e346c37e0343b0fb6f64f6be01" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains.kotlin" name="kotlin-stdlib-jdk7" version="1.4.21">
<artifact name="kotlin-stdlib-jdk7-1.4.21.jar">
<sha256 value="50de5f7dad6235064ac6c0ff577f095a91b3306c2547d8bc372291587495024a" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains.kotlin" name="kotlin-stdlib-jdk7" version="1.5.31">
<artifact name="kotlin-stdlib-jdk7-1.5.31.jar">
<sha256 value="a25bf47353ce899d843cbddee516d621a73473e7fba97f8d0301e7b4aed7c15f" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains.kotlin" name="kotlin-stdlib-jdk8" version="1.4.21">
<artifact name="kotlin-stdlib-jdk8-1.4.21.jar">
<sha256 value="8ec3db1516948b2d3524e3afbe75cb5ac59e02d98cb6ef586ef57ba63ca8d11f" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jetbrains.kotlin" name="kotlin-stdlib-jdk8" version="1.5.31">
<artifact name="kotlin-stdlib-jdk8-1.5.31.jar">
<sha256 value="b548f7767aacf029d2417e47440742bd6d3ebede19b60386e23554ce5c4c5fdc" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.jline" name="jline" version="3.9.0">
<artifact name="jline-3.9.0.jar">
<sha256 value="d2b986fd15d05e0b900faba776c1de9b4dc4a4fcdfeaa12a8ab8fb2b290ed527" origin="Generated by Gradle"/>
@ -3734,6 +3879,41 @@
<sha256 value="0b9a7c048ee2f607b00cb0749f554cc0b13c2a0c3d51180297b2d28ad03ee8e6" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.osgi" name="org.osgi.service.cm" version="1.6.1">
<artifact name="org.osgi.service.cm-1.6.1.jar">
<sha256 value="529da7b6806af4d788acc0aef0079c9c920f6cb1d2679c8f392ca552fb2e1d35" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.osgi" name="org.osgi.service.component" version="1.5.0">
<artifact name="org.osgi.service.component-1.5.0.jar">
<sha256 value="120a22db8758c0c2c27cb4a7686ca094150ca47067dc8a32d488d79e8beb3609" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.osgi" name="org.osgi.service.event" version="1.4.1">
<artifact name="org.osgi.service.event-1.4.1.jar">
<sha256 value="9f11c68980dbd931850f3f27fc7c35e1d710ecc728fe872bd6d786cd7e4b7b5e" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.osgi" name="org.osgi.service.metatype" version="1.4.1">
<artifact name="org.osgi.service.metatype-1.4.1.jar">
<sha256 value="83d9cc2b62500d2e438be91c157659c2d693a262cfd14eb9b916286ca627ed00" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.osgi" name="org.osgi.service.prefs" version="1.1.2">
<artifact name="org.osgi.service.prefs-1.1.2.jar">
<sha256 value="43c7c870710e363405d422da653cce0d798a4537f76e4930f79bceadd3a55345" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.osgi" name="org.osgi.util.function" version="1.2.0">
<artifact name="org.osgi.util.function-1.2.0.jar">
<sha256 value="208819c7c71690c15a6bb8b187474e7f9d0147946b680182a62b9f222ae014ec" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.osgi" name="org.osgi.util.promise" version="1.2.0">
<artifact name="org.osgi.util.promise-1.2.0.jar">
<sha256 value="fef86e64f584d012a16a0306160764f6179663b90988a226c4641b920f3a4b36" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="org.ow2.asm" name="asm" version="5.0.4">
<artifact name="asm-5.0.4.jar">
<sha256 value="896618ed8ae62702521a78bc7be42b7c491a08e6920a15f89a3ecdec31e9a220" origin="Generated by Gradle"/>

View file

@ -8,7 +8,7 @@
package org.elasticsearch.core;
public record Tuple<V1, V2> (V1 v1, V2 v2) {
public record Tuple<V1, V2>(V1 v1, V2 v2) {
public static <V1, V2> Tuple<V1, V2> tuple(V1 v1, V2 v2) {
return new Tuple<>(v1, v2);

View file

@ -45,7 +45,7 @@ public interface GrokCaptureExtracter {
// - GROK(pattern, "1") => { name: 1 }
// - GROK(pattern, "12") => { name: [1, 2] }
if (result.containsKey(key)) {
if (result.get(key)instanceof List<?> values) {
if (result.get(key) instanceof List<?> values) {
((ArrayList<Object>) values).add(value);
} else {
var values = new ArrayList<>();

View file

@ -43,7 +43,7 @@ public class MapXContentParser extends AbstractXContentParser {
@Override
protected boolean doBooleanValue() throws IOException {
if (iterator != null && iterator.currentValue()instanceof Boolean aBoolean) {
if (iterator != null && iterator.currentValue() instanceof Boolean aBoolean) {
return aBoolean;
} else {
throw new IllegalStateException("Cannot get boolean value for the current token " + currentToken());
@ -201,7 +201,7 @@ public class MapXContentParser extends AbstractXContentParser {
@Override
public byte[] binaryValue() throws IOException {
if (iterator != null && iterator.currentValue()instanceof byte[] bytes) {
if (iterator != null && iterator.currentValue() instanceof byte[] bytes) {
return bytes;
} else {
throw new IllegalStateException("Cannot get binary value for the current token " + currentToken());

View file

@ -86,7 +86,7 @@ public class TimeSeriesAggregatorTests extends AggregationTestCase {
fields.add(new LongPoint(DataStreamTimestampFieldMapper.DEFAULT_PATH, timestamp));
final TimeSeriesIdBuilder builder = new TimeSeriesIdBuilder(null);
for (int i = 0; i < dimensions.length; i += 2) {
if (dimensions[i + 1]instanceof Number n) {
if (dimensions[i + 1] instanceof Number n) {
builder.addLong(dimensions[i].toString(), n.longValue());
} else {
builder.addString(dimensions[i].toString(), dimensions[i + 1].toString());

View file

@ -246,10 +246,9 @@ public class SynonymsAnalysisTests extends ESTestCase {
.build();
IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings);
expectThrows(
IllegalArgumentException.class,
() -> { indexAnalyzers = createTestAnalysis(idxSettings, settings, new CommonAnalysisPlugin()).indexAnalyzers; }
);
expectThrows(IllegalArgumentException.class, () -> {
indexAnalyzers = createTestAnalysis(idxSettings, settings, new CommonAnalysisPlugin()).indexAnalyzers;
});
}
@ -301,7 +300,9 @@ public class SynonymsAnalysisTests extends ESTestCase {
IllegalArgumentException e = expectThrows(
IllegalArgumentException.class,
"Expected exception for factory " + tf.getName(),
() -> { tf.get(idxSettings, null, tf.getName(), settings).getSynonymFilter(); }
() -> {
tf.get(idxSettings, null, tf.getName(), settings).getSynonymFilter();
}
);
assertEquals(tf.getName(), "Token filter [" + tf.getName() + "] cannot be used to parse synonyms", e.getMessage());
disallowedFiltersTested.add(tf.getName());

View file

@ -41,11 +41,7 @@ class APMAgentSettings {
* Sensible defaults that Elasticsearch configures. This cannot be done via the APM agent
* config file, as then their values could not be overridden dynamically via system properties.
*/
// tag::noformat
static Map<String, String> APM_AGENT_DEFAULT_SETTINGS = Map.of(
"transaction_sample_rate", "0.2"
);
// end::noformat
static Map<String, String> APM_AGENT_DEFAULT_SETTINGS = Map.of("transaction_sample_rate", "0.2");
void addClusterSettingsListeners(ClusterService clusterService, APMTracer apmTracer) {
final ClusterSettings clusterSettings = clusterService.getClusterSettings();

View file

@ -132,14 +132,9 @@ public class DataStreamsStatsTests extends ESSingleNodeTestCase {
client().admin().indices().close(new CloseIndexRequest(".ds-" + dataStreamName + "-*-000001")).actionGet().isAcknowledged()
);
assertBusy(
() -> {
assertNotEquals(
ClusterHealthStatus.RED,
client().admin().cluster().health(new ClusterHealthRequest()).actionGet().getStatus()
);
}
);
assertBusy(() -> {
assertNotEquals(ClusterHealthStatus.RED, client().admin().cluster().health(new ClusterHealthRequest()).actionGet().getStatus());
});
DataStreamsStatsAction.Response stats = getDataStreamsStats();
assertEquals(2, stats.getSuccessfulShards());

View file

@ -130,7 +130,7 @@ final class TikaImpl {
// classpath
addReadPermissions(perms, JarHell.parseClassPath());
// plugin jars
if (TikaImpl.class.getClassLoader()instanceof URLClassLoader urlClassLoader) {
if (TikaImpl.class.getClassLoader() instanceof URLClassLoader urlClassLoader) {
URL[] urls = urlClassLoader.getURLs();
Set<URL> set = new LinkedHashSet<>(Arrays.asList(urls));
if (set.size() != urls.length) {

View file

@ -51,11 +51,9 @@ public class GeoIpCacheTests extends ESTestCase {
GeoIpCache cache = new GeoIpCache(1);
IllegalArgumentException ex = expectThrows(
IllegalArgumentException.class,
() -> cache.putIfAbsent(
InetAddresses.forString("127.0.0.1"),
"path/to/db",
ip -> { throw new IllegalArgumentException("bad"); }
)
() -> cache.putIfAbsent(InetAddresses.forString("127.0.0.1"), "path/to/db", ip -> {
throw new IllegalArgumentException("bad");
})
);
assertEquals("bad", ex.getMessage());
}

View file

@ -25,23 +25,15 @@ public class WhitelistLoaderTests extends ESTestCase {
public void testUnknownAnnotations() {
Map<String, WhitelistAnnotationParser> parsers = new HashMap<>(WhitelistAnnotationParser.BASE_ANNOTATION_PARSERS);
RuntimeException expected = expectThrows(
RuntimeException.class,
() -> { WhitelistLoader.loadFromResourceFiles(Whitelist.class, parsers, "org.elasticsearch.painless.annotation.unknown"); }
);
RuntimeException expected = expectThrows(RuntimeException.class, () -> {
WhitelistLoader.loadFromResourceFiles(Whitelist.class, parsers, "org.elasticsearch.painless.annotation.unknown");
});
assertEquals("invalid annotation: parser not found for [unknownAnnotation] [@unknownAnnotation]", expected.getCause().getMessage());
assertEquals(IllegalArgumentException.class, expected.getCause().getClass());
expected = expectThrows(
RuntimeException.class,
() -> {
WhitelistLoader.loadFromResourceFiles(
Whitelist.class,
parsers,
"org.elasticsearch.painless.annotation.unknown_with_options"
);
}
);
expected = expectThrows(RuntimeException.class, () -> {
WhitelistLoader.loadFromResourceFiles(Whitelist.class, parsers, "org.elasticsearch.painless.annotation.unknown_with_options");
});
assertEquals(
"invalid annotation: parser not found for [unknownAnnotationWithMessage] [@unknownAnnotationWithMessage[arg=\"arg value\"]]",
expected.getCause().getMessage()

View file

@ -335,7 +335,7 @@ public final class PainlessLookupBuilder {
}
canonicalClassNamesToClasses.put(importedCanonicalClassName.intern(), clazz);
if (annotations.get(AliasAnnotation.class)instanceof AliasAnnotation alias) {
if (annotations.get(AliasAnnotation.class) instanceof AliasAnnotation alias) {
Class<?> existing = canonicalClassNamesToClasses.put(alias.alias(), clazz);
if (existing != null) {
throw lookupException("Cannot add alias [%s] for [%s] that shadows class [%s]", alias.alias(), clazz, existing);

View file

@ -132,21 +132,13 @@ public class DefBootstrapTests extends ESTestCase {
map.put("a", "b");
assertEquals(2, (int) handle.invokeExact((Object) map));
final IllegalArgumentException iae = expectThrows(
IllegalArgumentException.class,
() -> { Integer.toString((int) handle.invokeExact(new Object())); }
);
final IllegalArgumentException iae = expectThrows(IllegalArgumentException.class, () -> {
Integer.toString((int) handle.invokeExact(new Object()));
});
assertEquals("dynamic method [java.lang.Object, size/0] not found", iae.getMessage());
assertTrue(
"Does not fail inside ClassValue.computeValue()",
Arrays.stream(iae.getStackTrace())
.anyMatch(
e -> {
return e.getMethodName().equals("computeValue")
&& e.getClassName().startsWith("org.elasticsearch.painless.DefBootstrap$PIC$");
}
)
);
assertTrue("Does not fail inside ClassValue.computeValue()", Arrays.stream(iae.getStackTrace()).anyMatch(e -> {
return e.getMethodName().equals("computeValue") && e.getClassName().startsWith("org.elasticsearch.painless.DefBootstrap$PIC$");
}));
}
// test operators with null guards

View file

@ -244,18 +244,16 @@ public class FunctionRefTests extends ScriptTestCase {
}
public void testMethodMissing() {
Exception e = expectScriptThrows(
IllegalArgumentException.class,
() -> { exec("List l = [2, 1]; l.sort(Integer::bogus); return l.get(0);"); }
);
Exception e = expectScriptThrows(IllegalArgumentException.class, () -> {
exec("List l = [2, 1]; l.sort(Integer::bogus); return l.get(0);");
});
assertThat(e.getMessage(), containsString("function reference [Integer::bogus/2] matching [java.util.Comparator"));
}
public void testQualifiedMethodMissing() {
Exception e = expectScriptThrows(
IllegalArgumentException.class,
() -> { exec("List l = [2, 1]; l.sort(java.time.Instant::bogus); return l.get(0);", false); }
);
Exception e = expectScriptThrows(IllegalArgumentException.class, () -> {
exec("List l = [2, 1]; l.sort(java.time.Instant::bogus); return l.get(0);", false);
});
assertThat(
e.getMessage(),
containsString("function reference [java.time.Instant::bogus/2] matching [java.util.Comparator, compare/2")
@ -263,26 +261,23 @@ public class FunctionRefTests extends ScriptTestCase {
}
public void testClassMissing() {
Exception e = expectScriptThrows(
IllegalArgumentException.class,
() -> { exec("List l = [2, 1]; l.sort(Bogus::bogus); return l.get(0);", false); }
);
Exception e = expectScriptThrows(IllegalArgumentException.class, () -> {
exec("List l = [2, 1]; l.sort(Bogus::bogus); return l.get(0);", false);
});
assertThat(e.getMessage(), endsWith("variable [Bogus] is not defined"));
}
public void testQualifiedClassMissing() {
Exception e = expectScriptThrows(
IllegalArgumentException.class,
() -> { exec("List l = [2, 1]; l.sort(org.package.BogusClass::bogus); return l.get(0);", false); }
);
Exception e = expectScriptThrows(IllegalArgumentException.class, () -> {
exec("List l = [2, 1]; l.sort(org.package.BogusClass::bogus); return l.get(0);", false);
});
assertEquals("variable [org.package.BogusClass] is not defined", e.getMessage());
}
public void testNotFunctionalInterface() {
IllegalArgumentException expected = expectScriptThrows(
IllegalArgumentException.class,
() -> { exec("List l = new ArrayList(); l.add(2); l.add(1); l.add(Integer::bogus); return l.get(0);"); }
);
IllegalArgumentException expected = expectScriptThrows(IllegalArgumentException.class, () -> {
exec("List l = new ArrayList(); l.add(2); l.add(1); l.add(Integer::bogus); return l.get(0);");
});
assertThat(
expected.getMessage(),
containsString("cannot convert function reference [Integer::bogus] to a non-functional interface [def]")
@ -290,17 +285,15 @@ public class FunctionRefTests extends ScriptTestCase {
}
public void testIncompatible() {
expectScriptThrows(
ClassCastException.class,
() -> { exec("List l = new ArrayList(); l.add(2); l.add(1); l.sort(String::startsWith); return l.get(0);"); }
);
expectScriptThrows(ClassCastException.class, () -> {
exec("List l = new ArrayList(); l.add(2); l.add(1); l.sort(String::startsWith); return l.get(0);");
});
}
public void testWrongArity() {
IllegalArgumentException expected = expectScriptThrows(
IllegalArgumentException.class,
() -> { exec("Optional.empty().orElseGet(String::startsWith);"); }
);
IllegalArgumentException expected = expectScriptThrows(IllegalArgumentException.class, () -> {
exec("Optional.empty().orElseGet(String::startsWith);");
});
assertThat(
expected.getMessage(),
containsString("function reference [String::startsWith/0] matching [java.util.function.Supplier")
@ -308,18 +301,16 @@ public class FunctionRefTests extends ScriptTestCase {
}
public void testWrongArityNotEnough() {
IllegalArgumentException expected = expectScriptThrows(
IllegalArgumentException.class,
() -> { exec("List l = new ArrayList(); l.add(2); l.add(1); l.sort(String::isEmpty);"); }
);
IllegalArgumentException expected = expectScriptThrows(IllegalArgumentException.class, () -> {
exec("List l = new ArrayList(); l.add(2); l.add(1); l.sort(String::isEmpty);");
});
assertThat(expected.getMessage(), containsString("function reference [String::isEmpty/2] matching [java.util.Comparator"));
}
public void testWrongArityDef() {
IllegalArgumentException expected = expectScriptThrows(
IllegalArgumentException.class,
() -> { exec("def y = Optional.empty(); return y.orElseGet(String::startsWith);"); }
);
IllegalArgumentException expected = expectScriptThrows(IllegalArgumentException.class, () -> {
exec("def y = Optional.empty(); return y.orElseGet(String::startsWith);");
});
assertThat(
expected.getMessage(),
containsString("function reference [String::startsWith/0] matching [java.util.function.Supplier")
@ -327,38 +318,33 @@ public class FunctionRefTests extends ScriptTestCase {
}
public void testWrongArityNotEnoughDef() {
IllegalArgumentException expected = expectScriptThrows(
IllegalArgumentException.class,
() -> { exec("def l = new ArrayList(); l.add(2); l.add(1); l.sort(String::isEmpty);"); }
);
IllegalArgumentException expected = expectScriptThrows(IllegalArgumentException.class, () -> {
exec("def l = new ArrayList(); l.add(2); l.add(1); l.sort(String::isEmpty);");
});
assertThat(expected.getMessage(), containsString("function reference [String::isEmpty/2] matching [java.util.Comparator"));
}
public void testReturnVoid() {
Throwable expected = expectScriptThrows(
ClassCastException.class,
() -> { exec("StringBuilder b = new StringBuilder(); List l = [1, 2]; l.stream().mapToLong(b::setLength).sum();"); }
);
Throwable expected = expectScriptThrows(ClassCastException.class, () -> {
exec("StringBuilder b = new StringBuilder(); List l = [1, 2]; l.stream().mapToLong(b::setLength).sum();");
});
assertThat(expected.getMessage(), containsString("Cannot cast from [void] to [long]."));
}
public void testReturnVoidDef() {
Exception expected = expectScriptThrows(
LambdaConversionException.class,
() -> { exec("StringBuilder b = new StringBuilder(); def l = [1, 2]; l.stream().mapToLong(b::setLength);"); }
);
Exception expected = expectScriptThrows(LambdaConversionException.class, () -> {
exec("StringBuilder b = new StringBuilder(); def l = [1, 2]; l.stream().mapToLong(b::setLength);");
});
assertThat(expected.getMessage(), containsString("lambda expects return type [long], but found return type [void]"));
expected = expectScriptThrows(
LambdaConversionException.class,
() -> { exec("def b = new StringBuilder(); def l = [1, 2]; l.stream().mapToLong(b::setLength);"); }
);
expected = expectScriptThrows(LambdaConversionException.class, () -> {
exec("def b = new StringBuilder(); def l = [1, 2]; l.stream().mapToLong(b::setLength);");
});
assertThat(expected.getMessage(), containsString("lambda expects return type [long], but found return type [void]"));
expected = expectScriptThrows(
LambdaConversionException.class,
() -> { exec("def b = new StringBuilder(); List l = [1, 2]; l.stream().mapToLong(b::setLength);"); }
);
expected = expectScriptThrows(LambdaConversionException.class, () -> {
exec("def b = new StringBuilder(); List l = [1, 2]; l.stream().mapToLong(b::setLength);");
});
assertThat(expected.getMessage(), containsString("lambda expects return type [long], but found return type [void]"));
}

View file

@ -58,10 +58,9 @@ public class FunctionTests extends ScriptTestCase {
}
public void testDuplicates() {
Exception expected = expectScriptThrows(
IllegalArgumentException.class,
() -> { exec("void test(int x) {x = 2;} void test(def y) {y = 3;} test()"); }
);
Exception expected = expectScriptThrows(IllegalArgumentException.class, () -> {
exec("void test(int x) {x = 2;} void test(def y) {y = 3;} test()");
});
assertThat(expected.getMessage(), containsString("found duplicate function"));
}
@ -84,23 +83,20 @@ public class FunctionTests extends ScriptTestCase {
public void testReturnVoid() {
assertEquals(null, exec("void test(StringBuilder b, int i) {b.setLength(i)} test(new StringBuilder(), 1)"));
Exception expected = expectScriptThrows(
IllegalArgumentException.class,
() -> { exec("int test(StringBuilder b, int i) {b.setLength(i)} test(new StringBuilder(), 1)"); }
);
Exception expected = expectScriptThrows(IllegalArgumentException.class, () -> {
exec("int test(StringBuilder b, int i) {b.setLength(i)} test(new StringBuilder(), 1)");
});
assertEquals(
"invalid function definition: " + "not all paths provide a return value for function [test] with [2] parameters",
expected.getMessage()
);
expected = expectScriptThrows(
ClassCastException.class,
() -> { exec("int test(StringBuilder b, int i) {return b.setLength(i)} test(new StringBuilder(), 1)"); }
);
expected = expectScriptThrows(ClassCastException.class, () -> {
exec("int test(StringBuilder b, int i) {return b.setLength(i)} test(new StringBuilder(), 1)");
});
assertEquals("Cannot cast from [void] to [int].", expected.getMessage());
expected = expectScriptThrows(
ClassCastException.class,
() -> { exec("def test(StringBuilder b, int i) {return b.setLength(i)} test(new StringBuilder(), 1)"); }
);
expected = expectScriptThrows(ClassCastException.class, () -> {
exec("def test(StringBuilder b, int i) {return b.setLength(i)} test(new StringBuilder(), 1)");
});
assertEquals("Cannot cast from [void] to [def].", expected.getMessage());
}
}

View file

@ -269,14 +269,12 @@ public class GeneralCastTests extends ScriptTestCase {
}
public void testIllegalVoidCasts() {
expectScriptThrows(
IllegalArgumentException.class,
() -> { exec("def map = ['a': 1,'b': 2,'c': 3]; map.c = Collections.sort(new ArrayList(map.keySet()));"); }
);
expectScriptThrows(
IllegalArgumentException.class,
() -> { exec("Map map = ['a': 1,'b': 2,'c': 3]; def x = new HashMap(); x.put(1, map.clear());"); }
);
expectScriptThrows(IllegalArgumentException.class, () -> {
exec("def map = ['a': 1,'b': 2,'c': 3]; map.c = Collections.sort(new ArrayList(map.keySet()));");
});
expectScriptThrows(IllegalArgumentException.class, () -> {
exec("Map map = ['a': 1,'b': 2,'c': 3]; def x = new HashMap(); x.put(1, map.clear());");
});
}
public void testBoxedDefCalls() {

View file

@ -149,28 +149,19 @@ public class LambdaTests extends ScriptTestCase {
}
public void testCapturesAreReadOnly() {
IllegalArgumentException expected = expectScriptThrows(
IllegalArgumentException.class,
() -> {
exec(
"List l = new ArrayList(); l.add(1); l.add(1); " + "return l.stream().mapToInt(x -> { l = null; return x + 1 }).sum();"
);
}
);
IllegalArgumentException expected = expectScriptThrows(IllegalArgumentException.class, () -> {
exec("List l = new ArrayList(); l.add(1); l.add(1); " + "return l.stream().mapToInt(x -> { l = null; return x + 1 }).sum();");
});
assertTrue(expected.getMessage().contains("is read-only"));
}
/** Lambda parameters shouldn't be able to mask a variable already in scope */
public void testNoParamMasking() {
IllegalArgumentException expected = expectScriptThrows(
IllegalArgumentException.class,
() -> {
exec(
"int x = 0; List l = new ArrayList(); l.add(1); l.add(1); "
+ "return l.stream().mapToInt(x -> { x += 1; return x }).sum();"
);
}
);
IllegalArgumentException expected = expectScriptThrows(IllegalArgumentException.class, () -> {
exec(
"int x = 0; List l = new ArrayList(); l.add(1); l.add(1); " + "return l.stream().mapToInt(x -> { x += 1; return x }).sum();"
);
});
assertTrue(expected.getMessage().contains("already defined"));
}
@ -190,36 +181,30 @@ public class LambdaTests extends ScriptTestCase {
}
public void testWrongArity() {
IllegalArgumentException expected = expectScriptThrows(
IllegalArgumentException.class,
false,
() -> { exec("Optional.empty().orElseGet(x -> x);"); }
);
IllegalArgumentException expected = expectScriptThrows(IllegalArgumentException.class, false, () -> {
exec("Optional.empty().orElseGet(x -> x);");
});
assertTrue(expected.getMessage().contains("Incorrect number of parameters"));
}
public void testWrongArityDef() {
IllegalArgumentException expected = expectScriptThrows(
IllegalArgumentException.class,
() -> { exec("def y = Optional.empty(); return y.orElseGet(x -> x);"); }
);
IllegalArgumentException expected = expectScriptThrows(IllegalArgumentException.class, () -> {
exec("def y = Optional.empty(); return y.orElseGet(x -> x);");
});
assertTrue(expected.getMessage(), expected.getMessage().contains("due to an incorrect number of arguments"));
}
public void testWrongArityNotEnough() {
IllegalArgumentException expected = expectScriptThrows(
IllegalArgumentException.class,
false,
() -> { exec("List l = new ArrayList(); l.add(1); l.add(1); " + "return l.stream().mapToInt(() -> 5).sum();"); }
);
IllegalArgumentException expected = expectScriptThrows(IllegalArgumentException.class, false, () -> {
exec("List l = new ArrayList(); l.add(1); l.add(1); " + "return l.stream().mapToInt(() -> 5).sum();");
});
assertTrue(expected.getMessage().contains("Incorrect number of parameters"));
}
public void testWrongArityNotEnoughDef() {
IllegalArgumentException expected = expectScriptThrows(
IllegalArgumentException.class,
() -> { exec("def l = new ArrayList(); l.add(1); l.add(1); " + "return l.stream().mapToInt(() -> 5).sum();"); }
);
IllegalArgumentException expected = expectScriptThrows(IllegalArgumentException.class, () -> {
exec("def l = new ArrayList(); l.add(1); l.add(1); " + "return l.stream().mapToInt(() -> 5).sum();");
});
assertTrue(expected.getMessage(), expected.getMessage().contains("due to an incorrect number of arguments"));
}
@ -284,19 +269,17 @@ public class LambdaTests extends ScriptTestCase {
}
public void testReturnVoid() {
Throwable expected = expectScriptThrows(
ClassCastException.class,
() -> { exec("StringBuilder b = new StringBuilder(); List l = [1, 2]; l.stream().mapToLong(i -> b.setLength(i))"); }
);
Throwable expected = expectScriptThrows(ClassCastException.class, () -> {
exec("StringBuilder b = new StringBuilder(); List l = [1, 2]; l.stream().mapToLong(i -> b.setLength(i))");
});
assertThat(expected.getMessage(), containsString("Cannot cast from [void] to [long]."));
}
public void testReturnVoidDef() {
// If we can catch the error at compile time we do
Exception expected = expectScriptThrows(
ClassCastException.class,
() -> { exec("StringBuilder b = new StringBuilder(); def l = [1, 2]; l.stream().mapToLong(i -> b.setLength(i))"); }
);
Exception expected = expectScriptThrows(ClassCastException.class, () -> {
exec("StringBuilder b = new StringBuilder(); def l = [1, 2]; l.stream().mapToLong(i -> b.setLength(i))");
});
assertThat(expected.getMessage(), containsString("Cannot cast from [void] to [def]."));
// Otherwise we convert the void into a null

View file

@ -14,20 +14,18 @@ public class OverloadTests extends ScriptTestCase {
public void testMethod() {
// assertEquals(2, exec("return 'abc123abc'.indexOf('c');"));
// assertEquals(8, exec("return 'abc123abc'.indexOf('c', 3);"));
IllegalArgumentException expected = expectScriptThrows(
IllegalArgumentException.class,
() -> { exec("return 'abc123abc'.indexOf('c', 3, 'bogus');"); }
);
IllegalArgumentException expected = expectScriptThrows(IllegalArgumentException.class, () -> {
exec("return 'abc123abc'.indexOf('c', 3, 'bogus');");
});
assertTrue(expected.getMessage().contains("[java.lang.String, indexOf/3]"));
}
public void testMethodDynamic() {
assertEquals(2, exec("def x = 'abc123abc'; return x.indexOf('c');"));
assertEquals(8, exec("def x = 'abc123abc'; return x.indexOf('c', 3);"));
IllegalArgumentException expected = expectScriptThrows(
IllegalArgumentException.class,
() -> { exec("def x = 'abc123abc'; return x.indexOf('c', 3, 'bogus');"); }
);
IllegalArgumentException expected = expectScriptThrows(IllegalArgumentException.class, () -> {
exec("def x = 'abc123abc'; return x.indexOf('c', 3, 'bogus');");
});
assertTrue(expected.getMessage().contains("dynamic method [java.lang.String, indexOf/3] not found"));
}

View file

@ -157,11 +157,9 @@ public class StringTests extends ScriptTestCase {
assertEquals('c', exec("String s = \"c\"; (char)s"));
assertEquals('c', exec("String s = 'c'; (char)s"));
ClassCastException expected = expectScriptThrows(
ClassCastException.class,
false,
() -> { assertEquals("cc", exec("return (String)(char)\"cc\"")); }
);
ClassCastException expected = expectScriptThrows(ClassCastException.class, false, () -> {
assertEquals("cc", exec("return (String)(char)\"cc\""));
});
assertTrue(expected.getMessage().contains("cannot cast java.lang.String with length not equal to one to char"));
expected = expectScriptThrows(ClassCastException.class, false, () -> { assertEquals("cc", exec("return (String)(char)'cc'")); });

View file

@ -37,10 +37,9 @@ public class WhenThingsGoWrongTests extends ScriptTestCase {
assertEquals(npe.getMessage(), "cannot access method/field [intValue] from a null def reference");
npe = expectScriptThrows(NullPointerException.class, () -> { exec("def x = [1, null]; for (y in x) y.intValue(); return null;"); });
assertEquals(npe.getMessage(), "cannot access method/field [intValue] from a null def reference");
npe = expectScriptThrows(
NullPointerException.class,
() -> { exec("def x = [1, 2L, 3.0, 'test', (byte)1, (short)1, (char)1, null]; for (y in x) y.toString(); return null;"); }
);
npe = expectScriptThrows(NullPointerException.class, () -> {
exec("def x = [1, 2L, 3.0, 'test', (byte)1, (short)1, (char)1, null]; for (y in x) y.toString(); return null;");
});
assertEquals(npe.getMessage(), "cannot access method/field [toString] from a null def reference");
}
@ -51,10 +50,9 @@ public class WhenThingsGoWrongTests extends ScriptTestCase {
public void testScriptStack() {
for (String type : new String[] { "String", "def " }) {
// trigger NPE at line 1 of the script
ScriptException exception = expectThrows(
ScriptException.class,
() -> { exec(type + " x = null; boolean y = x.isEmpty();\n" + "return y;"); }
);
ScriptException exception = expectThrows(ScriptException.class, () -> {
exec(type + " x = null; boolean y = x.isEmpty();\n" + "return y;");
});
// null deref at x.isEmpty(), the '.' is offset 30
assertScriptElementColumn(30, exception);
assertScriptStack(exception, "y = x.isEmpty();\n", " ^---- HERE");
@ -78,12 +76,9 @@ public class WhenThingsGoWrongTests extends ScriptTestCase {
assertThat(exception.getCause(), instanceOf(NullPointerException.class));
// trigger NPE at line 4 in script (inside conditional)
exception = expectThrows(
ScriptException.class,
() -> {
exec(type + " x = null;\n" + "boolean y = false;\n" + "if (!y) {\n" + " y = x.isEmpty();\n" + "}\n" + "return y;");
}
);
exception = expectThrows(ScriptException.class, () -> {
exec(type + " x = null;\n" + "boolean y = false;\n" + "if (!y) {\n" + " y = x.isEmpty();\n" + "}\n" + "return y;");
});
// null deref at x.isEmpty(), the '.' is offset 53
assertScriptElementColumn(53, exception);
assertScriptStack(exception, "y = x.isEmpty();\n}\n", " ^---- HERE");
@ -115,10 +110,9 @@ public class WhenThingsGoWrongTests extends ScriptTestCase {
}
public void testBogusParameter() {
IllegalArgumentException expected = expectThrows(
IllegalArgumentException.class,
() -> { exec("return 5;", null, Collections.singletonMap("bogusParameterKey", "bogusParameterValue"), true); }
);
IllegalArgumentException expected = expectThrows(IllegalArgumentException.class, () -> {
exec("return 5;", null, Collections.singletonMap("bogusParameterKey", "bogusParameterValue"), true);
});
assertTrue(expected.getMessage().contains("Unrecognized compile-time parameter"));
}
@ -172,10 +166,9 @@ public class WhenThingsGoWrongTests extends ScriptTestCase {
}
public void testIllegalDynamicMethod() {
IllegalArgumentException expected = expectScriptThrows(
IllegalArgumentException.class,
() -> { exec("def x = 'test'; return x.getClass().toString()"); }
);
IllegalArgumentException expected = expectScriptThrows(IllegalArgumentException.class, () -> {
exec("def x = 'test'; return x.getClass().toString()");
});
assertTrue(expected.getMessage().contains("dynamic method [java.lang.String, getClass/0] not found"));
}
@ -212,10 +205,9 @@ public class WhenThingsGoWrongTests extends ScriptTestCase {
}
public void testSecurityException() {
expectThrows(
SecurityException.class,
() -> { exec("params.v.get();", Map.of("v", (Supplier<String>) () -> { throw new SecurityException(); }), true); }
);
expectThrows(SecurityException.class, () -> {
exec("params.v.get();", Map.of("v", (Supplier<String>) () -> { throw new SecurityException(); }), true);
});
}
public void testOutOfMemoryError() {

View file

@ -315,7 +315,9 @@ public class ScaledFloatFieldMapper extends FieldMapper {
name(),
IndexNumericFieldData.NumericType.LONG,
valuesSourceType,
(dv, n) -> { throw new UnsupportedOperationException(); }
(dv, n) -> {
throw new UnsupportedOperationException();
}
).build(cache, breakerService);
return new ScaledFloatIndexFieldData(scaledValues, scalingFactor, ScaledFloatDocValuesField::new);
};

View file

@ -409,10 +409,9 @@ public class PercolatorQuerySearchIT extends ESIntegTestCase {
client().admin().indices().prepareRefresh().get();
logger.info("percolating empty doc with source disabled");
IllegalArgumentException e = expectThrows(
IllegalArgumentException.class,
() -> { client().prepareSearch().setQuery(new PercolateQueryBuilder("query", "test", "1", null, null, null)).get(); }
);
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> {
client().prepareSearch().setQuery(new PercolateQueryBuilder("query", "test", "1", null, null, null)).get();
});
assertThat(e.getMessage(), containsString("source disabled"));
}

View file

@ -228,10 +228,9 @@ public class PercolateQueryBuilderTests extends AbstractQueryTestCase<PercolateQ
}
public void testRequiredParameters() {
IllegalArgumentException e = expectThrows(
IllegalArgumentException.class,
() -> { new PercolateQueryBuilder(null, new BytesArray("{}"), XContentType.JSON); }
);
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> {
new PercolateQueryBuilder(null, new BytesArray("{}"), XContentType.JSON);
});
assertThat(e.getMessage(), equalTo("[field] is a required argument"));
e = expectThrows(

View file

@ -563,14 +563,9 @@ public class PercolatorFieldMapperTests extends ESSingleNodeTestCase {
)
);
BytesRef qbSource = doc.rootDoc().getFields(fieldType.queryBuilderField.name()).get(0).binaryValue();
SearchExecutionContext searchExecutionContext = indexService.newSearchExecutionContext(
randomInt(20),
0,
null,
() -> { throw new UnsupportedOperationException(); },
null,
emptyMap()
);
SearchExecutionContext searchExecutionContext = indexService.newSearchExecutionContext(randomInt(20), 0, null, () -> {
throw new UnsupportedOperationException();
}, null, emptyMap());
PlainActionFuture<QueryBuilder> future = new PlainActionFuture<>();
Rewriteable.rewriteAndFetch(queryBuilder, searchExecutionContext, future);
assertQueryBuilder(qbSource, future.get());

View file

@ -258,11 +258,9 @@ public class DiscountedCumulativeGain implements EvaluationMetric {
return builder;
}
private static final ConstructingObjectParser<Detail, Void> PARSER = new ConstructingObjectParser<>(
NAME,
true,
args -> { return new Detail((Double) args[0], (Double) args[1] != null ? (Double) args[1] : 0.0d, (Integer) args[2]); }
);
private static final ConstructingObjectParser<Detail, Void> PARSER = new ConstructingObjectParser<>(NAME, true, args -> {
return new Detail((Double) args[0], (Double) args[1] != null ? (Double) args[1] : 0.0d, (Integer) args[2]);
});
static {
PARSER.declareDouble(constructorArg(), DCG_FIELD);

View file

@ -238,11 +238,9 @@ public class ExpectedReciprocalRank implements EvaluationMetric {
return builder.field(UNRATED_FIELD.getPreferredName(), this.unratedDocs);
}
private static final ConstructingObjectParser<Detail, Void> PARSER = new ConstructingObjectParser<>(
NAME,
true,
args -> { return new Detail((Integer) args[0]); }
);
private static final ConstructingObjectParser<Detail, Void> PARSER = new ConstructingObjectParser<>(NAME, true, args -> {
return new Detail((Integer) args[0]);
});
static {
PARSER.declareInt(constructorArg(), UNRATED_FIELD);

View file

@ -195,11 +195,9 @@ public class MeanReciprocalRank implements EvaluationMetric {
return builder.field(FIRST_RELEVANT_RANK_FIELD.getPreferredName(), firstRelevantRank);
}
private static final ConstructingObjectParser<Detail, Void> PARSER = new ConstructingObjectParser<>(
NAME,
true,
args -> { return new Detail((Integer) args[0]); }
);
private static final ConstructingObjectParser<Detail, Void> PARSER = new ConstructingObjectParser<>(NAME, true, args -> {
return new Detail((Integer) args[0]);
});
static {
PARSER.declareInt(constructorArg(), FIRST_RELEVANT_RANK_FIELD);

View file

@ -311,11 +311,9 @@ public class DiscountedCumulativeGainTests extends ESTestCase {
}
public void testEqualsAndHash() throws IOException {
checkEqualsAndHashCode(
createTestItem(),
original -> { return new DiscountedCumulativeGain(original.getNormalize(), original.getUnknownDocRating(), original.getK()); },
DiscountedCumulativeGainTests::mutateTestItem
);
checkEqualsAndHashCode(createTestItem(), original -> {
return new DiscountedCumulativeGain(original.getNormalize(), original.getUnknownDocRating(), original.getK());
}, DiscountedCumulativeGainTests::mutateTestItem);
}
private static DiscountedCumulativeGain mutateTestItem(DiscountedCumulativeGain original) {

View file

@ -188,11 +188,9 @@ public class ExpectedReciprocalRankTests extends ESTestCase {
}
public void testEqualsAndHash() throws IOException {
checkEqualsAndHashCode(
createTestItem(),
original -> { return new ExpectedReciprocalRank(original.getMaxRelevance(), original.getUnknownDocRating(), original.getK()); },
ExpectedReciprocalRankTests::mutateTestItem
);
checkEqualsAndHashCode(createTestItem(), original -> {
return new ExpectedReciprocalRank(original.getMaxRelevance(), original.getUnknownDocRating(), original.getK());
}, ExpectedReciprocalRankTests::mutateTestItem);
}
private static ExpectedReciprocalRank mutateTestItem(ExpectedReciprocalRank original) {

View file

@ -67,11 +67,9 @@ public class RatedDocumentTests extends ESTestCase {
}
public void testEqualsAndHash() throws IOException {
checkEqualsAndHashCode(
createRatedDocument(),
original -> { return new RatedDocument(original.getIndex(), original.getDocID(), original.getRating()); },
RatedDocumentTests::mutateTestItem
);
checkEqualsAndHashCode(createRatedDocument(), original -> {
return new RatedDocument(original.getIndex(), original.getDocID(), original.getRating());
}, RatedDocumentTests::mutateTestItem);
}
private static RatedDocument mutateTestItem(RatedDocument original) {

View file

@ -108,7 +108,9 @@ public class BulkByScrollUsesAllScrollDocumentsAfterConflictsIntegTests extends
scriptEnabled,
updateByQuery(),
true,
(bulkByScrollResponse, updatedDocCount) -> { assertThat(bulkByScrollResponse.getUpdated(), is((long) updatedDocCount)); }
(bulkByScrollResponse, updatedDocCount) -> {
assertThat(bulkByScrollResponse.getUpdated(), is((long) updatedDocCount));
}
);
}
@ -130,7 +132,9 @@ public class BulkByScrollUsesAllScrollDocumentsAfterConflictsIntegTests extends
scriptEnabled,
reindexRequestBuilder,
false,
(bulkByScrollResponse, reindexDocCount) -> { assertThat(bulkByScrollResponse.getCreated(), is((long) reindexDocCount)); }
(bulkByScrollResponse, reindexDocCount) -> {
assertThat(bulkByScrollResponse.getCreated(), is((long) reindexDocCount));
}
);
}
@ -142,7 +146,9 @@ public class BulkByScrollUsesAllScrollDocumentsAfterConflictsIntegTests extends
false,
deleteByQuery(),
true,
(bulkByScrollResponse, deletedDocCount) -> { assertThat(bulkByScrollResponse.getDeleted(), is((long) deletedDocCount)); }
(bulkByScrollResponse, deletedDocCount) -> {
assertThat(bulkByScrollResponse.getDeleted(), is((long) deletedDocCount));
}
);
}

View file

@ -816,7 +816,7 @@ public class AzureBlobStore implements BlobStore {
)
);
} catch (Exception e) {
if (Throwables.getRootCause(e)instanceof BlobStorageException blobStorageException
if (Throwables.getRootCause(e) instanceof BlobStorageException blobStorageException
&& blobStorageException.getStatusCode() == RestStatus.NOT_FOUND.getStatus()) {
return OptionalLong.empty();
}
@ -838,7 +838,7 @@ public class AzureBlobStore implements BlobStore {
)
);
} catch (Exception e) {
if (Throwables.getRootCause(e)instanceof BlobStorageException blobStorageException) {
if (Throwables.getRootCause(e) instanceof BlobStorageException blobStorageException) {
if (blobStorageException.getStatusCode() == RestStatus.PRECONDITION_FAILED.getStatus()
|| blobStorageException.getStatusCode() == RestStatus.CONFLICT.getStatus()) {
return OptionalLong.empty();

View file

@ -92,10 +92,9 @@ public class AzureClientProviderTests extends ESTestCase {
LocationMode locationMode = LocationMode.SECONDARY_ONLY;
RequestRetryOptions requestRetryOptions = new RequestRetryOptions();
expectThrows(
IllegalArgumentException.class,
() -> { azureClientProvider.createClient(storageSettings, locationMode, requestRetryOptions, null, EMPTY_CONSUMER); }
);
expectThrows(IllegalArgumentException.class, () -> {
azureClientProvider.createClient(storageSettings, locationMode, requestRetryOptions, null, EMPTY_CONSUMER);
});
}
private static String encodeKey(final String value) {

View file

@ -245,9 +245,9 @@ public class URLHttpClientTests extends ESTestCase {
}
private URLHttpClient.HttpResponse executeRequest(String endpoint) throws Exception {
return AccessController.doPrivileged(
(PrivilegedExceptionAction<URLHttpClient.HttpResponse>) () -> { return httpClient.get(getURIForEndpoint(endpoint), Map.of()); }
);
return AccessController.doPrivileged((PrivilegedExceptionAction<URLHttpClient.HttpResponse>) () -> {
return httpClient.get(getURIForEndpoint(endpoint), Map.of());
});
}
private URI getURIForEndpoint(String endpoint) throws Exception {

View file

@ -105,12 +105,9 @@ public interface NamedGroupExtractor {
throw new IllegalArgumentException("emitted warnings: " + warnings);
}
return new Grok(
GrokBuiltinPatterns.legacyPatterns(),
pattern,
watchdog,
w -> { throw new IllegalArgumentException("grok [" + pattern + "] emitted a warning: " + w); }
);
return new Grok(GrokBuiltinPatterns.legacyPatterns(), pattern, watchdog, w -> {
throw new IllegalArgumentException("grok [" + pattern + "] emitted a warning: " + w);
});
} catch (RuntimeException e) {
throw new IllegalArgumentException("error compiling grok pattern [" + pattern + "]: " + e.getMessage(), e);
}

View file

@ -593,16 +593,9 @@ public class Netty4HttpServerTransportTests extends AbstractHttpServerTransportT
public void dispatchRequest(final RestRequest request, final RestChannel channel, final ThreadContext threadContext) {
try {
channel.sendResponse(
new RestResponse(
OK,
ChunkedRestResponseBody.fromXContent(
ignored -> Iterators.single(
(builder, params) -> { throw new AssertionError("should not be called for HEAD REQUEST"); }
),
ToXContent.EMPTY_PARAMS,
channel
)
)
new RestResponse(OK, ChunkedRestResponseBody.fromXContent(ignored -> Iterators.single((builder, params) -> {
throw new AssertionError("should not be called for HEAD REQUEST");
}), ToXContent.EMPTY_PARAMS, channel))
);
} catch (IOException e) {
throw new AssertionError(e);

View file

@ -52,9 +52,9 @@ public class HaHdfsFailoverTestSuiteIT extends ESRestTestCase {
String nn2Port = "10002";
if (ports.length() > 0) {
final Path path = PathUtils.get(ports);
final List<String> lines = AccessController.doPrivileged(
(PrivilegedExceptionAction<List<String>>) () -> { return Files.readAllLines(path); }
);
final List<String> lines = AccessController.doPrivileged((PrivilegedExceptionAction<List<String>>) () -> {
return Files.readAllLines(path);
});
nn1Port = lines.get(0);
nn2Port = lines.get(1);
}

View file

@ -44,10 +44,9 @@ public class NodeEnvironmentEvilTests extends ESTestCase {
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toAbsolutePath().toString())
.putList(Environment.PATH_DATA_SETTING.getKey(), tempPaths)
.build();
IllegalStateException exception = expectThrows(
IllegalStateException.class,
() -> { new NodeEnvironment(build, TestEnvironment.newEnvironment(build)); }
);
IllegalStateException exception = expectThrows(IllegalStateException.class, () -> {
new NodeEnvironment(build, TestEnvironment.newEnvironment(build));
});
assertTrue(
exception.getCause().getCause().getMessage(),
exception.getCause().getCause().getMessage().startsWith(path.toString())

View file

@ -274,7 +274,7 @@ public class EvilThreadPoolTests extends ESTestCase {
runExecutionTest(runner, runnable, willThrow, o -> {
assertEquals(willThrow, o.isPresent());
if (willThrow) {
if (o.get()instanceof Error error) throw error;
if (o.get() instanceof Error error) throw error;
assertThat(o.get(), instanceOf(IllegalStateException.class));
assertThat(o.get(), hasToString(containsString("future exception")));
}

View file

@ -231,11 +231,9 @@ public class ArchiveTests extends PackagingTestCase {
final Installation.Executables bin = installation.executables();
final String password = "some-keystore-password";
Platforms.onLinux(() -> bin.keystoreTool.run("passwd", password + "\n" + password + "\n"));
Platforms.onWindows(
() -> {
sh.run("Invoke-Command -ScriptBlock {echo '" + password + "'; echo '" + password + "'} | " + bin.keystoreTool + " passwd");
}
);
Platforms.onWindows(() -> {
sh.run("Invoke-Command -ScriptBlock {echo '" + password + "'; echo '" + password + "'} | " + bin.keystoreTool + " passwd");
});
Shell.Result result = runElasticsearchStartCommand("some-wrong-password-here", false, false);
assertElasticsearchFailure(result, "Provided keystore password was incorrect", null);
verifySecurityNotAutoConfigured(installation);

View file

@ -156,7 +156,7 @@ public class RemoteClustersIT extends AbstractMultiClusterRemoteTestCase {
Optional<Object> remoteConnectionInfo = getAsMap(restClient, "/_remote/info").values().stream().findFirst();
if (remoteConnectionInfo.isPresent()) {
logger.info("Connection info: {}", remoteConnectionInfo);
if (((Map<String, Object>) remoteConnectionInfo.get()).get("connected")instanceof Boolean connected) {
if (((Map<String, Object>) remoteConnectionInfo.get()).get("connected") instanceof Boolean connected) {
return connected;
}
}

View file

@ -488,14 +488,12 @@ public class TasksIT extends ESIntegTestCase {
if (index != null) {
index.join();
}
assertBusy(
() -> {
assertEquals(
emptyList(),
client().admin().cluster().prepareListTasks().setActions("indices:data/write/index*").get().getTasks()
);
}
);
assertBusy(() -> {
assertEquals(
emptyList(),
client().admin().cluster().prepareListTasks().setActions("indices:data/write/index*").get().getTasks()
);
});
}
}

View file

@ -81,18 +81,9 @@ public class BulkWithUpdatesIT extends ESIntegTestCase {
scripts.put("ctx._source.field2 = 'value2'", vars -> srcScript(vars, source -> source.replace("field2", "value2")));
scripts.put(
"throw script exception on unknown var",
vars -> {
throw new ScriptException(
"message",
null,
Collections.emptyList(),
"exception on unknown var",
CustomScriptPlugin.NAME
);
}
);
scripts.put("throw script exception on unknown var", vars -> {
throw new ScriptException("message", null, Collections.emptyList(), "exception on unknown var", CustomScriptPlugin.NAME);
});
scripts.put("ctx.op = \"none\"", vars -> ((Map<String, Object>) vars.get("ctx")).put("op", "none"));
scripts.put("ctx.op = \"delete\"", vars -> ((Map<String, Object>) vars.get("ctx")).put("op", "delete"));

View file

@ -196,7 +196,9 @@ public class PrevalidateNodeRemovalIT extends ESIntegTestCase {
MockTransportService node2TransportService = (MockTransportService) internalCluster().getInstance(TransportService.class, node2);
node2TransportService.addRequestHandlingBehavior(
TransportPrevalidateShardPathAction.ACTION_NAME + "[n]",
(handler, request, channel, task) -> { logger.info("drop the check shards request"); }
(handler, request, channel, task) -> {
logger.info("drop the check shards request");
}
);
PrevalidateNodeRemovalRequest req = PrevalidateNodeRemovalRequest.builder()
.setNames(node2)

View file

@ -79,11 +79,9 @@ public class TemplateUpgradeServiceIT extends ESIntegTestCase {
Tracer tracer,
AllocationService allocationService
) {
clusterService.getClusterSettings()
.addSettingsUpdateConsumer(
UPDATE_TEMPLATE_DUMMY_SETTING,
integer -> { logger.debug("the template dummy setting was updated to {}", integer); }
);
clusterService.getClusterSettings().addSettingsUpdateConsumer(UPDATE_TEMPLATE_DUMMY_SETTING, integer -> {
logger.debug("the template dummy setting was updated to {}", integer);
});
return super.createComponents(
client,
clusterService,

View file

@ -141,11 +141,9 @@ public class IndexShardIT extends ESSingleNodeTestCase {
final LockObtainFailedException exception = expectThrows(
LockObtainFailedException.class,
() -> env.deleteShardDirectoryUnderLock(
sLock,
indexSettings,
indexPaths -> { assert false : "should not be called " + indexPaths; }
)
() -> env.deleteShardDirectoryUnderLock(sLock, indexSettings, indexPaths -> {
assert false : "should not be called " + indexPaths;
})
);
assertThat(exception.getMessage(), exception.getMessage(), containsString("unable to acquire write.lock"));
}

View file

@ -263,10 +263,9 @@ public class IndexActionIT extends ESIntegTestCase {
}
public void testDocumentWithBlankFieldName() {
Exception e = expectThrows(
DocumentParsingException.class,
() -> { client().prepareIndex("test").setId("1").setSource("", "value1_2").execute().actionGet(); }
);
Exception e = expectThrows(DocumentParsingException.class, () -> {
client().prepareIndex("test").setId("1").setSource("", "value1_2").execute().actionGet();
});
assertThat(e.getMessage(), containsString("failed to parse"));
assertThat(e.getCause().getMessage(), containsString("field name cannot be an empty string"));
}

View file

@ -114,11 +114,9 @@ public class UpdateSettingsIT extends ESIntegTestCase {
@Override
public void onIndexModule(IndexModule indexModule) {
indexModule.addSettingsUpdateConsumer(
DUMMY_SETTING,
(s) -> {},
(s) -> { if (s.equals("boom")) throw new IllegalArgumentException("this setting goes boom"); }
);
indexModule.addSettingsUpdateConsumer(DUMMY_SETTING, (s) -> {}, (s) -> {
if (s.equals("boom")) throw new IllegalArgumentException("this setting goes boom");
});
}
@Override

View file

@ -176,7 +176,7 @@ public class TransportClusterHealthAction extends TransportMasterNodeReadAction<
static boolean isExpectedFailure(Exception e) {
return e instanceof NotMasterException
|| e instanceof FailedToCommitClusterStateException
&& e.getCause()instanceof EsRejectedExecutionException esre
&& e.getCause() instanceof EsRejectedExecutionException esre
&& esre.isExecutorShutdown();
}
});

View file

@ -94,14 +94,13 @@ public class TransportPostFeatureUpgradeAction extends TransportMasterNodeAction
SYSTEM_INDEX_UPGRADE_TASK_NAME,
SYSTEM_INDEX_UPGRADE_TASK_NAME,
new SystemIndexMigrationTaskParams(),
ActionListener.wrap(
startedTask -> { listener.onResponse(new PostFeatureUpgradeResponse(true, featuresToMigrate, null, null)); },
ex -> {
logger.error("failed to start system index upgrade task", ex);
ActionListener.wrap(startedTask -> {
listener.onResponse(new PostFeatureUpgradeResponse(true, featuresToMigrate, null, null));
}, ex -> {
logger.error("failed to start system index upgrade task", ex);
listener.onResponse(new PostFeatureUpgradeResponse(false, null, null, new ElasticsearchException(ex)));
}
)
listener.onResponse(new PostFeatureUpgradeResponse(false, null, null, new ElasticsearchException(ex)));
})
);
} else {
listener.onResponse(new PostFeatureUpgradeResponse(false, null, "No system indices require migration", null));

View file

@ -33,7 +33,9 @@ public class ClusterUpdateSettingsResponse extends AcknowledgedResponse {
private static final ConstructingObjectParser<ClusterUpdateSettingsResponse, Void> PARSER = new ConstructingObjectParser<>(
"cluster_update_settings_response",
true,
args -> { return new ClusterUpdateSettingsResponse((boolean) args[0], (Settings) args[1], (Settings) args[2]); }
args -> {
return new ClusterUpdateSettingsResponse((boolean) args[0], (Settings) args[1], (Settings) args[2]);
}
);
static {
declareAcknowledgedField(PARSER);

View file

@ -188,11 +188,9 @@ public class TransportAnalyzeAction extends TransportSingleShardAction<AnalyzeAc
MappedFieldType fieldType = indexService.mapperService().fieldType(request.field());
if (fieldType != null) {
if (fieldType instanceof StringFieldType) {
return indexService.mapperService()
.indexAnalyzer(
fieldType.name(),
f -> { throw new IllegalArgumentException("No analyzer configured for field " + fieldType.name()); }
);
return indexService.mapperService().indexAnalyzer(fieldType.name(), f -> {
throw new IllegalArgumentException("No analyzer configured for field " + fieldType.name());
});
} else {
throw new IllegalArgumentException(
"Can't process field [" + request.field() + "], Analysis requests are only supported on tokenized fields"

View file

@ -61,7 +61,9 @@ public class FieldCapabilitiesFailure implements Writeable, ToXContentObject {
private static final ConstructingObjectParser<FieldCapabilitiesFailure, Void> PARSER = new ConstructingObjectParser<>(
"field_capabilities_failure",
true,
a -> { return new FieldCapabilitiesFailure(((List<String>) a[0]).toArray(String[]::new), (Exception) a[1]); }
a -> {
return new FieldCapabilitiesFailure(((List<String>) a[0]).toArray(String[]::new), (Exception) a[1]);
}
);
static {

View file

@ -48,10 +48,9 @@ class SimulateExecutionService {
pipeline.getMetadata(),
verbosePipelineProcessor
);
ingestDocument.executePipeline(
verbosePipeline,
(result, e) -> { handler.accept(new SimulateDocumentVerboseResult(processorResultList), e); }
);
ingestDocument.executePipeline(verbosePipeline, (result, e) -> {
handler.accept(new SimulateDocumentVerboseResult(processorResultList), e);
});
} else {
ingestDocument.executePipeline(pipeline, (result, e) -> {
if (e == null) {

View file

@ -557,7 +557,9 @@ public class SearchTransportService {
QUERY_CAN_MATCH_NAME,
ThreadPool.Names.SAME,
ShardSearchRequest::new,
(request, channel, task) -> { searchService.canMatch(request, new ChannelActionListener<>(channel)); }
(request, channel, task) -> {
searchService.canMatch(request, new ChannelActionListener<>(channel));
}
);
TransportActionProxy.registerProxyAction(transportService, QUERY_CAN_MATCH_NAME, true, CanMatchShardResponse::new);
@ -565,7 +567,9 @@ public class SearchTransportService {
QUERY_CAN_MATCH_NODE_NAME,
ThreadPool.Names.SEARCH_COORDINATION,
CanMatchNodeRequest::new,
(request, channel, task) -> { searchService.canMatch(request, new ChannelActionListener<>(channel)); }
(request, channel, task) -> {
searchService.canMatch(request, new ChannelActionListener<>(channel));
}
);
TransportActionProxy.registerProxyAction(transportService, QUERY_CAN_MATCH_NODE_NAME, true, CanMatchNodeResponse::new);
}

View file

@ -261,7 +261,7 @@ public class SubscribableListener<T> implements ActionListener<T> {
}
}
private record SuccessResult<T> (T result) {
private record SuccessResult<T>(T result) {
public void complete(ActionListener<T> listener) {
try {
listener.onResponse(result);

View file

@ -152,7 +152,7 @@ public class NodeClient extends AbstractClient {
return namedWriteableRegistry;
}
private record SafelyWrappedActionListener<Response> (ActionListener<Response> listener) implements ActionListener<Response> {
private record SafelyWrappedActionListener<Response>(ActionListener<Response> listener) implements ActionListener<Response> {
@Override
public void onResponse(Response response) {

View file

@ -197,7 +197,7 @@ public interface ClusterStateTaskExecutor<T extends ClusterStateTaskListener> {
* emitted response headers, for cases where things like deprecation warnings may be emitted but
* cannot be associated with any specific task.
*/
record BatchExecutionContext<T extends ClusterStateTaskListener> (
record BatchExecutionContext<T extends ClusterStateTaskListener>(
ClusterState initialState,
List<? extends TaskContext<T>> taskContexts,
Supplier<Releasable> dropHeadersContextSupplier

View file

@ -209,7 +209,7 @@ public class InternalClusterInfoService implements ClusterInfoService, ClusterSt
if (indicesStatsResponse.getShardFailures().length > 0) {
final Set<String> failedNodeIds = new HashSet<>();
for (final var shardFailure : indicesStatsResponse.getShardFailures()) {
if (shardFailure.getCause()instanceof final FailedNodeException failedNodeException) {
if (shardFailure.getCause() instanceof final FailedNodeException failedNodeException) {
if (failedNodeIds.add(failedNodeException.nodeId())) {
logger.warn(
() -> format(

View file

@ -395,7 +395,7 @@ public abstract class Publication {
private Exception getRootCause(Exception e) {
if (e instanceof final TransportException transportException) {
if (transportException.getRootCause()instanceof final Exception rootCause) {
if (transportException.getRootCause() instanceof final Exception rootCause) {
return rootCause;
} else {
assert false : e;

View file

@ -54,12 +54,9 @@ public class NodesShutdownMetadata implements Metadata.Custom {
});
static {
PARSER.declareNamedObjects(
ConstructingObjectParser.constructorArg(),
(p, c, n) -> SingleNodeShutdownMetadata.parse(p),
v -> { throw new IllegalArgumentException("ordered " + NODES_FIELD.getPreferredName() + " are not supported"); },
NODES_FIELD
);
PARSER.declareNamedObjects(ConstructingObjectParser.constructorArg(), (p, c, n) -> SingleNodeShutdownMetadata.parse(p), v -> {
throw new IllegalArgumentException("ordered " + NODES_FIELD.getPreferredName() + " are not supported");
}, NODES_FIELD);
}
public static NodesShutdownMetadata fromXContent(XContentParser parser) {

View file

@ -93,5 +93,5 @@ public class AllocationActionMultiListener<T> {
return listeners;
}
private record DelayedListener<T> (ActionListener<T> listener, T response) {}
private record DelayedListener<T>(ActionListener<T> listener, T response) {}
}

View file

@ -262,7 +262,7 @@ public class DesiredBalanceShardsAllocator implements ShardsAllocator {
@Override
public void onFailure(Exception e) {
assert MasterService.isPublishFailureException(e) : e;
if (e.getCause() != null && e.getCause()instanceof EsRejectedExecutionException esRejectedExecutionException) {
if (e.getCause() != null && e.getCause() instanceof EsRejectedExecutionException esRejectedExecutionException) {
assert esRejectedExecutionException.isExecutorShutdown();
// TODO now what? onNoLongerMaster() asserts it's on the master thread but we could be anywhere here
} else {

View file

@ -1525,7 +1525,7 @@ public class MasterService extends AbstractLifecycleComponent {
return "BatchingTaskQueue[" + name + "]";
}
private record Entry<T extends ClusterStateTaskListener> (
private record Entry<T extends ClusterStateTaskListener>(
String source,
T task,
long insertionIndex,

View file

@ -37,7 +37,7 @@ public final class CustomMapFieldsConverter extends LogEventPatternConverter {
@Override
public void format(LogEvent event, StringBuilder toAppendTo) {
if (event.getMessage()instanceof ESLogMessage logMessage) {
if (event.getMessage() instanceof ESLogMessage logMessage) {
logMessage.addJsonNoBrackets(toAppendTo);
}
}

View file

@ -217,15 +217,9 @@ public class Maps {
Function<T, ? extends K> keyMapper,
Function<T, ? extends V> valueMapper
) {
return Collectors.collectingAndThen(
Collectors.toMap(
keyMapper,
valueMapper,
(v1, v2) -> { throw new IllegalStateException("Duplicate key (attempted merging values " + v1 + " and " + v2 + ")"); },
() -> new TreeMap<K, V>()
),
Collections::unmodifiableNavigableMap
);
return Collectors.collectingAndThen(Collectors.toMap(keyMapper, valueMapper, (v1, v2) -> {
throw new IllegalStateException("Duplicate key (attempted merging values " + v1 + " and " + v2 + ")");
}, () -> new TreeMap<K, V>()), Collections::unmodifiableNavigableMap);
}
/**
@ -239,15 +233,9 @@ public class Maps {
Function<T, ? extends K> keyMapper,
Function<T, ? extends V> valueMapper
) {
return Collectors.collectingAndThen(
Collectors.toMap(
keyMapper,
valueMapper,
(v1, v2) -> { throw new IllegalStateException("Duplicate key (attempted merging values " + v1 + " and " + v2 + ")"); },
(Supplier<LinkedHashMap<K, V>>) LinkedHashMap::new
),
Collections::unmodifiableMap
);
return Collectors.collectingAndThen(Collectors.toMap(keyMapper, valueMapper, (v1, v2) -> {
throw new IllegalStateException("Duplicate key (attempted merging values " + v1 + " and " + v2 + ")");
}, (Supplier<LinkedHashMap<K, V>>) LinkedHashMap::new), Collections::unmodifiableMap);
}
/**
@ -314,7 +302,7 @@ public class Maps {
* @param key key
* @param value value
*/
public record ImmutableEntry<KType, VType> (KType key, VType value) implements Map.Entry<KType, VType> {
public record ImmutableEntry<KType, VType>(KType key, VType value) implements Map.Entry<KType, VType> {
@Override
public KType getKey() {

View file

@ -125,7 +125,7 @@ public class EsThreadPoolExecutor extends ThreadPoolExecutor {
StringBuilder b = new StringBuilder();
b.append(getClass().getSimpleName()).append('[');
b.append("name = ").append(name).append(", ");
if (getQueue()instanceof SizeBlockingQueue<?> queue) {
if (getQueue() instanceof SizeBlockingQueue<?> queue) {
b.append("queue capacity = ").append(queue.capacity()).append(", ");
}
appendThreadPoolExecutorDetails(b);

View file

@ -74,7 +74,7 @@ public class FutureUtils {
}
public static RuntimeException rethrowExecutionException(ExecutionException e) {
if (e.getCause()instanceof RuntimeException runtimeException) {
if (e.getCause() instanceof RuntimeException runtimeException) {
return runtimeException;
} else {
return new UncategorizedExecutionException("Failed execution", e);

View file

@ -650,7 +650,9 @@ public final class IndexModule {
parserConfiguration,
new SimilarityService(indexSettings, scriptService, similarities),
mapperRegistry,
() -> { throw new UnsupportedOperationException("no index query shard context available"); },
() -> {
throw new UnsupportedOperationException("no index query shard context available");
},
indexSettings.getMode().idFieldMapperWithoutFieldData(),
scriptService
);

View file

@ -742,10 +742,9 @@ public final class IndexSettings {
mode = scopedSettings.get(MODE);
this.timestampBounds = mode.getTimestampBound(indexMetadata);
if (timestampBounds != null) {
scopedSettings.addSettingsUpdateConsumer(
IndexSettings.TIME_SERIES_END_TIME,
endTime -> { this.timestampBounds = TimestampBounds.updateEndTime(this.timestampBounds, endTime); }
);
scopedSettings.addSettingsUpdateConsumer(IndexSettings.TIME_SERIES_END_TIME, endTime -> {
this.timestampBounds = TimestampBounds.updateEndTime(this.timestampBounds, endTime);
});
}
this.searchThrottled = INDEX_SEARCH_THROTTLED.get(settings);
this.queryStringLenient = QUERY_STRING_LENIENT_SETTING.get(settings);

View file

@ -247,10 +247,9 @@ public final class IndexSortConfig {
}
IndexFieldData<?> fieldData;
try {
fieldData = fieldDataLookup.apply(
ft,
() -> { throw new UnsupportedOperationException("index sorting not supported on runtime field [" + ft.name() + "]"); }
);
fieldData = fieldDataLookup.apply(ft, () -> {
throw new UnsupportedOperationException("index sorting not supported on runtime field [" + ft.name() + "]");
});
} catch (Exception e) {
throw new IllegalArgumentException("docvalues not found for index sort field:[" + sortSpec.field + "]", e);
}

View file

@ -607,7 +607,9 @@ public final class AnalysisRegistry implements Closeable {
charFilterFactoryFactories,
tokenizerFactoryFactories
),
(k, v) -> { throw new IllegalStateException("already registered analyzer with name: " + entry.getKey()); }
(k, v) -> {
throw new IllegalStateException("already registered analyzer with name: " + entry.getKey());
}
);
}
for (Map.Entry<String, AnalyzerProvider<?>> entry : normalizerProviders.entrySet()) {

View file

@ -35,8 +35,8 @@ public class IndexFieldDataService extends AbstractIndexComponent implements Clo
FIELDDATA_CACHE_KEY,
FIELDDATA_CACHE_VALUE_NODE,
(s) -> switch (s) {
case "node", "none" -> s;
default -> throw new IllegalArgumentException("failed to parse [" + s + "] must be one of [node,none]");
case "node", "none" -> s;
default -> throw new IllegalArgumentException("failed to parse [" + s + "] must be one of [node,none]");
},
Property.IndexScope
);

View file

@ -48,13 +48,13 @@ public abstract class IgnoreMalformedStoredValues {
return switch (parser.currentToken()) {
case VALUE_STRING -> new StoredField(name, parser.text());
case VALUE_NUMBER -> switch (parser.numberType()) {
case INT -> new StoredField(name, parser.intValue());
case LONG -> new StoredField(name, parser.longValue());
case DOUBLE -> new StoredField(name, parser.doubleValue());
case FLOAT -> new StoredField(name, parser.floatValue());
case BIG_INTEGER -> new StoredField(name, encode((BigInteger) parser.numberValue()));
case BIG_DECIMAL -> new StoredField(name, encode((BigDecimal) parser.numberValue()));
};
case INT -> new StoredField(name, parser.intValue());
case LONG -> new StoredField(name, parser.longValue());
case DOUBLE -> new StoredField(name, parser.doubleValue());
case FLOAT -> new StoredField(name, parser.floatValue());
case BIG_INTEGER -> new StoredField(name, encode((BigInteger) parser.numberValue()));
case BIG_DECIMAL -> new StoredField(name, encode((BigDecimal) parser.numberValue()));
};
case VALUE_BOOLEAN -> new StoredField(name, new byte[] { parser.booleanValue() ? (byte) 't' : (byte) 'f' });
case VALUE_EMBEDDED_OBJECT -> new StoredField(name, encode(parser.binaryValue()));
case START_OBJECT, START_ARRAY -> {

View file

@ -29,10 +29,9 @@ public class MapperBuilderContext {
* A context to use to build metadata fields.
*/
public static MapperBuilderContext forMetadata() {
return new MapperBuilderContext(
null,
() -> { throw new UnsupportedOperationException("metadata fields can't check if _source is synthetic"); }
);
return new MapperBuilderContext(null, () -> {
throw new UnsupportedOperationException("metadata fields can't check if _source is synthetic");
});
}
private final String path;

View file

@ -214,14 +214,9 @@ public interface RuntimeField extends ToXContentFragment {
throw new IllegalStateException("Found sub-fields with name not belonging to the parent field they are part of " + names);
}
return runtimeField.asMappedFieldTypes();
})
.collect(
Collectors.toUnmodifiableMap(
MappedFieldType::name,
mappedFieldType -> mappedFieldType,
(t, t2) -> { throw new IllegalArgumentException("Found two runtime fields with same name [" + t.name() + "]"); }
)
);
}).collect(Collectors.toUnmodifiableMap(MappedFieldType::name, mappedFieldType -> mappedFieldType, (t, t2) -> {
throw new IllegalArgumentException("Found two runtime fields with same name [" + t.name() + "]");
}));
}
static <T> Function<FieldMapper, T> initializerNotSupported() {

View file

@ -492,9 +492,9 @@ public class SearchExecutionContext extends QueryRewriteContext {
*/
public SearchLookup lookup() {
if (this.lookup == null) {
SourceProvider sourceProvider = isSourceSynthetic()
? (ctx, doc) -> { throw new IllegalArgumentException("Cannot access source from scripts in synthetic mode"); }
: SourceProvider.fromStoredFields();
SourceProvider sourceProvider = isSourceSynthetic() ? (ctx, doc) -> {
throw new IllegalArgumentException("Cannot access source from scripts in synthetic mode");
} : SourceProvider.fromStoredFields();
setLookupProviders(sourceProvider, LeafFieldLookupProvider.fromStoredFields());
}
return this.lookup;

View file

@ -1949,11 +1949,15 @@ public class Translog extends AbstractIndexShardComponent implements IndexShardC
EMPTY_TRANSLOG_BUFFER_SIZE,
minTranslogGeneration,
initialGlobalCheckpoint,
() -> { throw new UnsupportedOperationException(); },
() -> {
throw new UnsupportedOperationException();
},
() -> { throw new UnsupportedOperationException(); },
primaryTerm,
new TragicExceptionHolder(),
seqNo -> { throw new UnsupportedOperationException(); },
seqNo -> {
throw new UnsupportedOperationException();
},
BigArrays.NON_RECYCLING_INSTANCE,
DiskIoBufferPool.INSTANCE,
(d, s, l) -> {}

View file

@ -185,7 +185,7 @@ public abstract class MultiChunkTransfer<Source, Request extends MultiChunkTrans
protected abstract void handleError(Source resource, Exception e) throws Exception;
private record FileChunkResponseItem<Source> (long requestSeqId, Source source, Exception failure) {}
private record FileChunkResponseItem<Source>(long requestSeqId, Source source, Exception failure) {}
public interface ChunkRequest {
/**

View file

@ -54,4 +54,4 @@ public class TransportMyAction extends TransportMasterNodeAction<MyRequest, MyRe
* @param <I> The interface class
* @param <T> The implementation class
*/
public record PluginComponentBinding<I, T extends I> (Class<? extends I> inter, T impl) {}
public record PluginComponentBinding<I, T extends I>(Class<? extends I> inter, T impl) {}

View file

@ -47,13 +47,11 @@ public class IndexSnapshotsService {
ShardId shardId,
ActionListener<Optional<ShardSnapshotInfo>> originalListener
) {
final ActionListener<Optional<ShardSnapshotInfo>> listener = originalListener.delegateResponse(
(delegate, err) -> {
delegate.onFailure(
new RepositoryException(repositoryName, "Unable to find the latest snapshot for shard [" + shardId + "]", err)
);
}
);
final ActionListener<Optional<ShardSnapshotInfo>> listener = originalListener.delegateResponse((delegate, err) -> {
delegate.onFailure(
new RepositoryException(repositoryName, "Unable to find the latest snapshot for shard [" + shardId + "]", err)
);
});
final Repository repository = getRepository(repositoryName);
if (repository == null) {

View file

@ -222,7 +222,7 @@ public class CtxMap<T extends Metadata> extends AbstractMap<String, Object> {
@Override
public boolean remove(Object o) {
if (o instanceof Map.Entry<?, ?> entry) {
if (entry.getKey()instanceof String key) {
if (entry.getKey() instanceof String key) {
if (metadata.containsKey(key)) {
if (Objects.equals(entry.getValue(), metadata.get(key))) {
metadata.remove(key);

View file

@ -306,7 +306,7 @@ public class Metadata {
* @param writable - can the field be updated after the initial set
* @param extendedValidation - value validation after type checking, may be used for values that may be one of a set
*/
public record FieldProperty<T> (Class<T> type, boolean nullable, boolean writable, BiConsumer<String, T> extendedValidation) {
public record FieldProperty<T>(Class<T> type, boolean nullable, boolean writable, BiConsumer<String, T> extendedValidation) {
public FieldProperty(Class<T> type) {
this(type, false, false, null);

View file

@ -1115,23 +1115,13 @@ public class SearchModule {
);
registerQuery(new QuerySpec<>(GeoShapeQueryBuilder.NAME, GeoShapeQueryBuilder::new, GeoShapeQueryBuilder::fromXContent));
registerQuery(
new QuerySpec<>(
KnnVectorQueryBuilder.NAME,
KnnVectorQueryBuilder::new,
parser -> {
throw new IllegalArgumentException("[knn] queries cannot be provided directly, use the [knn] body parameter instead");
}
)
);
registerQuery(new QuerySpec<>(KnnVectorQueryBuilder.NAME, KnnVectorQueryBuilder::new, parser -> {
throw new IllegalArgumentException("[knn] queries cannot be provided directly, use the [knn] body parameter instead");
}));
registerQuery(
new QuerySpec<>(
KnnScoreDocQueryBuilder.NAME,
KnnScoreDocQueryBuilder::new,
parser -> { throw new IllegalArgumentException("[score_doc] queries cannot be provided directly"); }
)
);
registerQuery(new QuerySpec<>(KnnScoreDocQueryBuilder.NAME, KnnScoreDocQueryBuilder::new, parser -> {
throw new IllegalArgumentException("[score_doc] queries cannot be provided directly");
}));
registerFromPlugin(plugins, SearchPlugin::getQueries, this::registerQuery);

View file

@ -20,7 +20,7 @@ import java.util.function.Supplier;
/**
* Dependencies used to reduce aggs.
*/
public abstract sealed class AggregationReduceContext permits AggregationReduceContext.ForPartial,AggregationReduceContext.ForFinal {
public abstract sealed class AggregationReduceContext permits AggregationReduceContext.ForPartial, AggregationReduceContext.ForFinal {
/**
* Builds {@link AggregationReduceContext}s.
*/

View file

@ -630,7 +630,7 @@ public final class CompositeAggregator extends BucketsAggregator implements Size
@Override
public void collectDebugInfo(BiConsumer<String, Object> add) {
super.collectDebugInfo(add);
if (sources[0]instanceof GlobalOrdinalValuesSource globalOrdinalValuesSource) {
if (sources[0] instanceof GlobalOrdinalValuesSource globalOrdinalValuesSource) {
globalOrdinalValuesSource.collectDebugInfo(Strings.format("sources.%s", sourceConfigs[0].name()), add);
}
}

View file

@ -81,7 +81,7 @@ final class CompositeValuesCollectorQueue extends PriorityQueue<Integer> impleme
// If the leading source is a GlobalOrdinalValuesSource we can apply an optimization which requires
// tracking the highest competitive value.
if (arrays[0]instanceof GlobalOrdinalValuesSource globalOrdinalValuesSource) {
if (arrays[0] instanceof GlobalOrdinalValuesSource globalOrdinalValuesSource) {
if (shouldApplyGlobalOrdinalDynamicPruningForLeadingSource(sources, size, indexReader)) {
competitiveBoundsChangedListener = topSlot -> globalOrdinalValuesSource.updateHighestCompetitiveValue(topSlot);
} else {
@ -103,7 +103,7 @@ final class CompositeValuesCollectorQueue extends PriorityQueue<Integer> impleme
if (sources.length == 0) {
return false;
}
if (sources[0]instanceof GlobalOrdinalValuesSource firstSource) {
if (sources[0] instanceof GlobalOrdinalValuesSource firstSource) {
if (firstSource.mayDynamicallyPrune(indexReader) == false) {
return false;
}

Some files were not shown because too many files have changed in this diff Show more