Skip to content

Commit

Permalink
Merge branch 'main' into fix/serverless-scope-comment
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jul 4, 2023
2 parents 69677f3 + 7ba5f5e commit 153e6d7
Show file tree
Hide file tree
Showing 194 changed files with 2,037 additions and 1,047 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,11 @@
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.inject.Inject;
import java.io.Serializable;

import javax.inject.Inject;

/**
* Checks files for license headers..
*/
Expand Down Expand Up @@ -193,9 +189,8 @@ public void runRat() {
boolean unApprovedLicenses = stats.getNumUnApproved() > 0;
if (unknownLicenses || unApprovedLicenses) {
getLogger().error("The following files contain unapproved license headers:");
unapprovedFiles(repFile).stream().forEachOrdered(unapprovedFile -> getLogger().error(unapprovedFile));
throw new GradleException("Check failed. License header problems were found. Full details: " +
repFile.getAbsolutePath());
unapprovedFiles(repFile).forEach(getLogger()::error);
throw new GradleException("Check failed. License header problems were found. Full details: " + repFile.getAbsolutePath());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.inject.Inject;

Expand Down Expand Up @@ -287,7 +288,7 @@ static Map<String, String> parseOsRelease(final List<String> osReleaseLines) {
*/
private Optional<String> getDockerPath() {
// Check if the Docker binary exists
return List.of(DOCKER_BINARIES).stream().filter(path -> new File(path).exists()).findFirst();
return Stream.of(DOCKER_BINARIES).filter(path -> new File(path).exists()).findFirst();
}

/**
Expand All @@ -298,7 +299,7 @@ private Optional<String> getDockerPath() {
*/
private Optional<String> getDockerComposePath() {
// Check if the Docker binary exists
return List.of(DOCKER_COMPOSE_BINARIES).stream().filter(path -> new File(path).exists()).findFirst();
return Stream.of(DOCKER_COMPOSE_BINARIES).filter(path -> new File(path).exists()).findFirst();
}

private void throwDockerRequiredException(final String message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,19 @@ public void checkInvalidPatterns() throws IOException {
} catch (UncheckedIOException e) {
throw new IllegalArgumentException("Failed to read " + f + " as UTF_8", e);
}
List<Integer> invalidLines = IntStream.range(0, lines.size())
.filter(i -> allPatterns.matcher(lines.get(i)).find())
.boxed()
.collect(Collectors.toList());

URI baseUri = getRootDir().orElse(projectLayout.getProjectDirectory().getAsFile()).get().toURI();
String path = baseUri.relativize(f.toURI()).toString();
failures.addAll(
invalidLines.stream()
.map(l -> new AbstractMap.SimpleEntry<>(l + 1, lines.get(l)))
.flatMap(
kv -> patterns.entrySet()
.stream()
.filter(p -> Pattern.compile(p.getValue()).matcher(kv.getValue()).find())
.map(p -> "- " + p.getKey() + " on line " + kv.getKey() + " of " + path)
)
.collect(Collectors.toList())
);
IntStream.range(0, lines.size())
.filter(i -> allPatterns.matcher(lines.get(i)).find())
.mapToObj(l -> new AbstractMap.SimpleEntry<>(l + 1, lines.get(l)))
.flatMap(
kv -> patterns.entrySet()
.stream()
.filter(p -> Pattern.compile(p.getValue()).matcher(kv.getValue()).find())
.map(p -> "- " + p.getKey() + " on line " + kv.getKey() + " of " + path)
)
.forEach(failures::add);
}
if (failures.isEmpty() == false) {
throw new GradleException("Found invalid patterns:\n" + String.join("\n", failures));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ private static ModuleReference esModuleFor(File filePath) {
return ModuleFinder.of(filePath.toPath())
.findAll()
.stream()
.sorted(Comparator.comparing(ModuleReference::descriptor))
.findFirst()
.min(Comparator.comparing(ModuleReference::descriptor))
.orElseThrow(() -> new GradleException("module not found in " + filePath));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import java.util.Set;
import java.util.TreeSet;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import javax.inject.Inject;

Expand Down Expand Up @@ -234,7 +233,7 @@ private void filterSplitPackages(Map<String, Set<String>> splitPackages) {
String lastPackageName = null;
Set<String> currentClasses = null;
boolean filterErrorsFound = false;
for (String fqcn : getParameters().getIgnoreClasses().get().stream().sorted().collect(Collectors.toList())) {
for (String fqcn : getParameters().getIgnoreClasses().get().stream().sorted().toList()) {
int lastDot = fqcn.lastIndexOf('.');
if (lastDot == -1) {
LOGGER.error("Missing package in classname in split package ignores: " + fqcn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.inject.Inject;

Expand Down Expand Up @@ -128,7 +129,7 @@ private void assertNoMissmatchingTest(List<? extends Class<?>> testClassesCandid
var mismatchingBaseClasses = testClassesCandidate.stream()
.filter(testClassDefaultPredicate)
.filter(TestingConventionsCheckWorkAction::seemsLikeATest)
.collect(Collectors.toList());
.toList();
if (mismatchingBaseClasses.isEmpty() == false) {
throw new GradleException(
"Following test classes do not extend any supported base class:\n\t"
Expand All @@ -141,7 +142,7 @@ private void assertMatchesSuffix(List<String> suffixes, List<Class> matchingBase
// ensure base class matching do match suffix
var matchingBaseClassNotMatchingSuffix = matchingBaseClass.stream()
.filter(c -> suffixes.stream().allMatch(s -> c.getName().endsWith(s) == false))
.collect(Collectors.toList());
.toList();
if (matchingBaseClassNotMatchingSuffix.isEmpty() == false) {
throw new GradleException(
"Following test classes do not match naming convention to use suffix "
Expand Down Expand Up @@ -202,8 +203,7 @@ private static boolean matchesTestMethodNamingConvention(Method method) {
}

private static boolean isAnnotated(Method method, Class<?> annotation) {
return List.of(method.getAnnotations())
.stream()
return Stream.of(method.getAnnotations())
.anyMatch(presentAnnotation -> annotation.isAssignableFrom(presentAnnotation.getClass()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,11 @@ private List<ElasticsearchDistribution> configureDistributions(Project project)
List<ElasticsearchDistribution> currentDistros = new ArrayList<>();

for (Architecture architecture : Architecture.values()) {
ALL_INTERNAL.stream()
.forEach(
type -> currentDistros.add(
createDistro(distributions, architecture, type, null, true, VersionProperties.getElasticsearch())
)
);
ALL_INTERNAL.forEach(
type -> currentDistros.add(
createDistro(distributions, architecture, type, null, true, VersionProperties.getElasticsearch())
)
);
}

for (Architecture architecture : Architecture.values()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ public List<ObjectNode> transformRestTests(LinkedList<ObjectNode> tests, List<Re
List<RestTestTransformGlobalSetup> setupTransforms = transformations.stream()
.filter(transform -> transform instanceof RestTestTransformGlobalSetup)
.map(transform -> (RestTestTransformGlobalSetup) transform)
.collect(Collectors.toList());
.toList();

// Collect any global teardown transformations
List<RestTestTransformGlobalTeardown> teardownTransforms = transformations.stream()
.filter(transform -> transform instanceof RestTestTransformGlobalTeardown)
.map(transform -> (RestTestTransformGlobalTeardown) transform)
.collect(Collectors.toList());
.toList();

// Collect any transformations that are identified by an object key.
Map<String, List<RestTestTransformByParentObject>> objectKeyFinders = transformations.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ private Optional<AdoptiumVersionInfo> resolveAvailableVersion(AdoptiumVersionReq
return Optional.of(
Lists.newArrayList(versionsNode.iterator())
.stream()
.map(node -> toVersionInfo(node))
.sorted(Comparator.comparing(AdoptiumVersionInfo::semver).reversed())
.findFirst()
.map(this::toVersionInfo)
.max(Comparator.comparing(AdoptiumVersionInfo::semver))
.get()
);
} catch (FileNotFoundException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void checkVersion(Project project, String tool, Pattern versionRegex, int... min
}

String version = matcher.group(1);
List<Integer> versionParts = Stream.of(version.split("\\.")).map(Integer::parseInt).collect(Collectors.toList());
List<Integer> versionParts = Stream.of(version.split("\\.")).map(Integer::parseInt).toList();
for (int i = 0; i < minVersion.length; ++i) {
int found = versionParts.get(i);
if (found > minVersion[i]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.Arrays;
import java.util.List;
import java.util.function.UnaryOperator;
import java.util.stream.Collectors;

import static org.elasticsearch.gradle.internal.vagrant.VagrantMachine.convertLinuxPath;
import static org.elasticsearch.gradle.internal.vagrant.VagrantMachine.convertWindowsPath;
Expand Down Expand Up @@ -71,7 +70,7 @@ public void runScript() {
script.add("try {");
script.add("cd " + convertWindowsPath(buildLayout.getRootDirectory(), buildLayout.getRootDirectory().toString()));
extension.getVmEnv().forEach((k, v) -> script.add("$Env:" + k + " = \"" + v + "\""));
script.addAll(getWindowsScript().stream().map(s -> " " + s).collect(Collectors.toList()));
script.addAll(getWindowsScript().stream().map(s -> " " + s).toList());
script.addAll(
Arrays.asList(
" exit $LASTEXITCODE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.nio.file.Paths;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
Expand Down Expand Up @@ -62,7 +61,7 @@ public static void main(String[] args) throws Exception {

private void reap() {
try (Stream<Path> stream = Files.list(inputDir)) {
final List<Path> inputFiles = stream.filter(p -> p.getFileName().toString().endsWith(".cmd")).collect(Collectors.toList());
final List<Path> inputFiles = stream.filter(p -> p.getFileName().toString().endsWith(".cmd")).toList();

for (Path inputFile : inputFiles) {
System.out.println("Process file: " + inputFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Object[] toArray() {

@Override
public <T1> T1[] toArray(T1[] a) {
return delegate.stream().peek(this::validate).map(PropertyListEntry::getValue).collect(Collectors.toList()).toArray(a);
return delegate.stream().peek(this::validate).map(PropertyListEntry::getValue).toList().toArray(a);
}

@Override
Expand All @@ -79,7 +79,7 @@ public boolean remove(Object o) {

@Override
public boolean containsAll(Collection<?> c) {
return delegate.stream().map(PropertyListEntry::getValue).collect(Collectors.toList()).containsAll(c);
return delegate.stream().map(PropertyListEntry::getValue).collect(Collectors.toSet()).containsAll(c);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void beforeStart() {
entry -> entry.getValue().toString()
)
);
boolean singleNode = getClusters().stream().flatMap(c -> c.getNodes().stream()).count() == 1;
boolean singleNode = getClusters().stream().mapToLong(c -> c.getNodes().size()).sum() == 1;
final Function<ElasticsearchNode, Path> getDataPath;
if (singleNode) {
getDataPath = n -> dataDir;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ default void useCluster(ElasticsearchCluster cluster) {
}

cluster.getNodes()
.all(node -> node.getDistributions().stream().forEach(distro -> dependsOn(getProject().provider(() -> distro.maybeFreeze()))));
.all(node -> node.getDistributions().forEach(distro -> dependsOn(getProject().provider(() -> distro.maybeFreeze()))));
cluster.getNodes().all(node -> dependsOn((Callable<Collection<Configuration>>) node::getPluginAndModuleConfigurations));
getClusters().add(cluster);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.lang.management.ManagementFactory;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public abstract class AbstractBenchmark<T extends Closeable> {
private static final int SEARCH_BENCHMARK_ITERATIONS = 10_000;
Expand Down Expand Up @@ -92,7 +91,7 @@ private void runSearchBenchmark(String[] args) throws Exception {
String benchmarkTargetHost = args[1];
String indexName = args[2];
String searchBody = args[3];
List<Integer> throughputRates = Arrays.asList(args[4].split(",")).stream().map(Integer::valueOf).collect(Collectors.toList());
List<Integer> throughputRates = Arrays.stream(args[4].split(",")).map(Integer::valueOf).toList();

T client = client(benchmarkTargetHost);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.Locale;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.zip.GZIPOutputStream;

Expand Down Expand Up @@ -74,15 +73,15 @@ private void copyTgzToTarget(Path source, Path target) throws IOException {
return;
}
try (Stream<Path> files = Files.list(source)) {
for (Path path : files.filter(p -> p.getFileName().toString().endsWith(".tgz")).collect(Collectors.toList())) {
for (Path path : files.filter(p -> p.getFileName().toString().endsWith(".tgz")).toList()) {
Files.copy(path, target.resolve(path.getFileName()), StandardCopyOption.REPLACE_EXISTING);
}
}
}

private void packDatabasesToTgz(Terminal terminal, Path source, Path target) throws IOException {
try (Stream<Path> files = Files.list(source)) {
for (Path path : files.filter(p -> p.getFileName().toString().endsWith(".mmdb")).collect(Collectors.toList())) {
for (Path path : files.filter(p -> p.getFileName().toString().endsWith(".mmdb")).toList()) {
String fileName = path.getFileName().toString();
Path compressedPath = target.resolve(fileName.replaceAll("mmdb$", "") + "tgz");
terminal.println("Found " + fileName + ", will compress it to " + compressedPath.getFileName());
Expand Down Expand Up @@ -111,7 +110,7 @@ private void createOverviewJson(Terminal terminal, Path directory) throws IOExce
XContentGenerator generator = XContentType.JSON.xContent().createGenerator(os)
) {
generator.writeStartArray();
for (Path db : files.filter(p -> p.getFileName().toString().endsWith(".tgz")).collect(Collectors.toList())) {
for (Path db : files.filter(p -> p.getFileName().toString().endsWith(".tgz")).toList()) {
terminal.println("Adding " + db.getFileName() + " to overview.json");
MessageDigest md5 = MessageDigests.md5();
try (InputStream dis = new DigestInputStream(new BufferedInputStream(Files.newInputStream(db)), md5)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

final class SystemJvmOptions {

static List<String> systemJvmOptions() {
return List.of(
return Stream.of(
/*
* Cache ttl in seconds for positive DNS lookups noting that this overrides the JDK security property networkaddress.cache.ttl;
* can be set to -1 to cache forever.
Expand Down Expand Up @@ -61,7 +62,7 @@ static List<String> systemJvmOptions() {
*/
"--add-opens=java.base/java.io=org.elasticsearch.preallocate",
maybeOverrideDockerCgroup()
).stream().filter(e -> e.isEmpty() == false).collect(Collectors.toList());
).filter(e -> e.isEmpty() == false).collect(Collectors.toList());
}

/*
Expand Down
5 changes: 5 additions & 0 deletions docs/changelog/96689.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 96689
summary: Use a collector manager in DfsPhase Knn Search
area: Search
type: enhancement
issues: []
6 changes: 6 additions & 0 deletions docs/changelog/96930.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 96930
summary: Include more downsampling status statistics
area: TSDB
type: enhancement
issues:
- 96760
6 changes: 6 additions & 0 deletions docs/changelog/97251.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 97251
summary: Chunk the GET _ilm/policy response
area: ILM+SLM
type: enhancement
issues:
- 96569
5 changes: 5 additions & 0 deletions docs/changelog/97281.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 97281
summary: Improve iterating over many field producers during downsample operation
area: Downsampling
type: enhancement
issues: []
6 changes: 6 additions & 0 deletions docs/changelog/97290.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 97290
summary: Handle failure in `TransportUpdateAction#handleUpdateFailureWithRetry`
area: CRUD
type: bug
issues:
- 97286
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private EmbeddedImplClassLoader(ClassLoader parent, Map<JarMeta, CodeSource> pre
.collect(toUnmodifiableMap(k -> k.getKey().prefix(), Map.Entry::getValue));
Map<String, JarMeta> map = new HashMap<>();
for (var jarMeta : prefixToCodeBase.keySet()) {
jarMeta.packages().stream().forEach(pkg -> {
jarMeta.packages().forEach(pkg -> {
var prev = map.put(pkg, jarMeta);
assert prev == null;
});
Expand Down
Loading

0 comments on commit 153e6d7

Please sign in to comment.