Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fix_map_exception_h…
Browse files Browse the repository at this point in the history
…andling
  • Loading branch information
henningandersen committed Jan 16, 2020
2 parents 0dae4f4 + aa66d1a commit b62a2b7
Show file tree
Hide file tree
Showing 659 changed files with 20,082 additions and 9,758 deletions.
11 changes: 0 additions & 11 deletions .ci/jobs.t/elastic+elasticsearch+{branch}+docker-test-ramdisk.yml

This file was deleted.

6 changes: 3 additions & 3 deletions .eclipseformat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references" value="48"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_logical_operator" value="48"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
Expand Down Expand Up @@ -129,7 +129,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="48"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_parameters" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_parameters" value="48"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="48"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="64"/>
Expand Down Expand Up @@ -242,7 +242,7 @@
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line" value="one_line_if_single_item"/>
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_arguments" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_arguments" value="48"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*.ipr
*.iws
build-idea/
# These files are generated in the main tree by IntelliJ
benchmarks/src/main/generated/*

# eclipse files
.project
Expand Down Expand Up @@ -42,7 +44,7 @@ html_docs
/tmp/
eclipse-build

# projects using testfixtures
# projects using testfixtures
testfixtures_shared/

# These are generated from .ci/jobs.t
Expand Down
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ subprojects {
// is greater than the number of unformatted projects, this can be
// switched to an exclude list, and eventualy removed completely.
def projectPathsToFormat = [
':build-tools',
':x-pack:plugin:enrich'
]

Expand All @@ -114,6 +115,10 @@ subprojects {

spotless {
java {
// Normally this isn't necessary, but we have Java sources in
// non-standard places
target '**/*.java'

removeUnusedImports()
eclipse().configFile rootProject.file('.eclipseformat.xml')
trimTrailingWhitespace()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ public static void main(String[] args) throws Exception {
}
Path inputDir = Paths.get(args[0]);

try (Reaper reaper = new Reaper(inputDir)){
try (Reaper reaper = new Reaper(inputDir)) {
System.in.read();
reaper.reap();
}
}

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

for (Path inputFile : inputFiles) {
Expand Down Expand Up @@ -118,7 +118,7 @@ private void delete(Path toDelete) {
@Override
public void close() {
if (failed == false) {
try (Stream<Path> stream = Files.walk(inputDir)){
try (Stream<Path> stream = Files.walk(inputDir)) {
stream.sorted(Comparator.reverseOrder()).forEach(this::delete);
} catch (IOException e) {
throw new UncheckedIOException(e);
Expand Down
108 changes: 47 additions & 61 deletions buildSrc/src/main/java/org/elasticsearch/gradle/BwcVersions.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,20 @@ public BwcVersions(List<String> versionLines) {
}

protected BwcVersions(List<String> versionLines, Version currentVersionProperty) {
this(versionLines.stream()
.map(LINE_PATTERN::matcher)
.filter(Matcher::matches)
.map(match -> new Version(
Integer.parseInt(match.group(1)),
Integer.parseInt(match.group(2)),
Integer.parseInt(match.group(3))
))
.collect(Collectors.toCollection(TreeSet::new)), currentVersionProperty);
this(
versionLines.stream()
.map(LINE_PATTERN::matcher)
.filter(Matcher::matches)
.map(
match -> new Version(
Integer.parseInt(match.group(1)),
Integer.parseInt(match.group(2)),
Integer.parseInt(match.group(3))
)
)
.collect(Collectors.toCollection(TreeSet::new)),
currentVersionProperty
);
}

// for testkit tests, until BwcVersions is extracted into an extension
Expand All @@ -140,27 +145,29 @@ public BwcVersions(SortedSet<Version> allVersions, Version currentVersionPropert

Map<Version, UnreleasedVersionInfo> unreleased = new HashMap<>();
for (Version unreleasedVersion : getUnreleased()) {
unreleased.put(unreleasedVersion,
new UnreleasedVersionInfo(unreleasedVersion, getBranchFor(unreleasedVersion), getGradleProjectPathFor(unreleasedVersion)));
unreleased.put(
unreleasedVersion,
new UnreleasedVersionInfo(unreleasedVersion, getBranchFor(unreleasedVersion), getGradleProjectPathFor(unreleasedVersion))
);
}
this.unreleased = Collections.unmodifiableMap(unreleased);
}

private void assertNoOlderThanTwoMajors() {
Set<Integer> majors = groupByMajor.keySet();
if (majors.size() != 2 && currentVersion.getMinor() != 0 && currentVersion.getRevision() != 0) {
throw new IllegalStateException(
"Expected exactly 2 majors in parsed versions but found: " + majors
);
throw new IllegalStateException("Expected exactly 2 majors in parsed versions but found: " + majors);
}
}

private void assertCurrentVersionMatchesParsed(Version currentVersionProperty) {
if (currentVersionProperty.equals(currentVersion) == false) {
throw new IllegalStateException(
"Parsed versions latest version does not match the one configured in build properties. " +
"Parsed latest version is " + currentVersion + " but the build has " +
currentVersionProperty
"Parsed versions latest version does not match the one configured in build properties. "
+ "Parsed latest version is "
+ currentVersion
+ " but the build has "
+ currentVersionProperty
);
}
}
Expand All @@ -175,12 +182,7 @@ public UnreleasedVersionInfo unreleasedInfo(Version version) {
public void forPreviousUnreleased(Consumer<UnreleasedVersionInfo> consumer) {
List<UnreleasedVersionInfo> collect = getUnreleased().stream()
.filter(version -> version.equals(currentVersion) == false)
.map(version -> new UnreleasedVersionInfo(
version,
getBranchFor(version),
getGradleProjectPathFor(version)
)
)
.map(version -> new UnreleasedVersionInfo(version, getBranchFor(version), getGradleProjectPathFor(version)))
.collect(Collectors.toList());

collect.forEach(uvi -> consumer.accept(uvi));
Expand All @@ -196,22 +198,18 @@ private String getGradleProjectPathFor(Version version) {
Map<Integer, List<Version>> releasedMajorGroupedByMinor = getReleasedMajorGroupedByMinor();

if (version.getRevision() == 0) {
List<Version> unreleasedStagedOrMinor = getUnreleased().stream()
.filter(v -> v.getRevision() == 0)
.collect(Collectors.toList());
List<Version> unreleasedStagedOrMinor = getUnreleased().stream().filter(v -> v.getRevision() == 0).collect(Collectors.toList());
if (unreleasedStagedOrMinor.size() > 2) {
if (unreleasedStagedOrMinor.get(unreleasedStagedOrMinor.size() - 2).equals(version)) {
return ":distribution:bwc:minor";
} else{
} else {
return ":distribution:bwc:staged";
}
} else {
return ":distribution:bwc:minor";
}
} else {
if (releasedMajorGroupedByMinor
.getOrDefault(version.getMinor(), emptyList())
.contains(version)) {
if (releasedMajorGroupedByMinor.getOrDefault(version.getMinor(), emptyList()).contains(version)) {
return ":distribution:bwc:bugfix";
} else {
return ":distribution:bwc:maintenance";
Expand All @@ -229,7 +227,7 @@ private String getBranchFor(Version version) {
return "master";
case ":distribution:bwc:minor":
// The .x branch will always point to the latest minor (for that major), so a "minor" project will be on the .x branch
// unless there is more recent (higher) minor.
// unless there is more recent (higher) minor.
final Version latestInMajor = getLatestVersionByKey(groupByMajor, version.getMajor());
if (latestInMajor.getMinor() == version.getMinor()) {
return version.getMajor() + ".x";
Expand Down Expand Up @@ -279,23 +277,16 @@ public List<Version> getUnreleased() {
}
}

return unmodifiableList(
unreleased.stream()
.sorted()
.distinct()
.collect(Collectors.toList())
);
return unmodifiableList(unreleased.stream().sorted().distinct().collect(Collectors.toList()));
}

private Version getLatestInMinor(int major, int minor) {
return groupByMajor.get(major).stream()
.filter(v -> v.getMinor() == minor)
.max(Version::compareTo)
.orElse(null);
return groupByMajor.get(major).stream().filter(v -> v.getMinor() == minor).max(Version::compareTo).orElse(null);
}

private Version getLatestVersionByKey(Map<Integer, List<Version>> groupByMajor, int key) {
return groupByMajor.getOrDefault(key, emptyList()).stream()
return groupByMajor.getOrDefault(key, emptyList())
.stream()
.max(Version::compareTo)
.orElseThrow(() -> new IllegalStateException("Unexpected number of versions in collection"));
}
Expand All @@ -307,11 +298,9 @@ private Map<Integer, List<Version>> getReleasedMajorGroupedByMinor() {
final Map<Integer, List<Version>> groupByMinor;
if (currentMajorVersions.size() == 1) {
// Current is an unreleased major: x.0.0 so we have to look for other unreleased versions in the previous major
groupByMinor = previousMajorVersions.stream()
.collect(Collectors.groupingBy(Version::getMinor, Collectors.toList()));
groupByMinor = previousMajorVersions.stream().collect(Collectors.groupingBy(Version::getMinor, Collectors.toList()));
} else {
groupByMinor = currentMajorVersions.stream()
.collect(Collectors.groupingBy(Version::getMinor, Collectors.toList()));
groupByMinor = currentMajorVersions.stream().collect(Collectors.groupingBy(Version::getMinor, Collectors.toList()));
}
return groupByMinor;
}
Expand All @@ -321,37 +310,37 @@ public void compareToAuthoritative(List<Version> authoritativeReleasedVersions)
notReallyReleased.removeAll(authoritativeReleasedVersions);
if (notReallyReleased.isEmpty() == false) {
throw new IllegalStateException(
"out-of-date released versions" +
"\nFollowing versions are not really released, but the build thinks they are: " + notReallyReleased
"out-of-date released versions"
+ "\nFollowing versions are not really released, but the build thinks they are: "
+ notReallyReleased
);
}

Set<Version> incorrectlyConsideredUnreleased = new HashSet<>(authoritativeReleasedVersions);
incorrectlyConsideredUnreleased.retainAll(getUnreleased());
if (incorrectlyConsideredUnreleased.isEmpty() == false) {
throw new IllegalStateException(
"out-of-date released versions" +
"\nBuild considers versions unreleased, " +
"but they are released according to an authoritative source: " + incorrectlyConsideredUnreleased +
"\nThe next versions probably needs to be added to Version.java (CURRENT doesn't count)."
"out-of-date released versions"
+ "\nBuild considers versions unreleased, "
+ "but they are released according to an authoritative source: "
+ incorrectlyConsideredUnreleased
+ "\nThe next versions probably needs to be added to Version.java (CURRENT doesn't count)."
);
}
}

private List<Version> getReleased() {
List<Version> unreleased = getUnreleased();
return groupByMajor.values().stream()
return groupByMajor.values()
.stream()
.flatMap(Collection::stream)
.filter(each -> unreleased.contains(each) == false)
.collect(Collectors.toList());
}

public List<Version> getIndexCompatible() {
return unmodifiableList(
Stream.concat(
groupByMajor.get(currentVersion.getMajor() - 1).stream(),
groupByMajor.get(currentVersion.getMajor()).stream()
)
Stream.concat(groupByMajor.get(currentVersion.getMajor() - 1).stream(), groupByMajor.get(currentVersion.getMajor()).stream())
.collect(Collectors.toList())
);
}
Expand All @@ -361,10 +350,7 @@ public List<Version> getWireCompatible() {

List<Version> prevMajors = groupByMajor.get(currentVersion.getMajor() - 1);
int minor = prevMajors.get(prevMajors.size() - 1).getMinor();
for (int i = prevMajors.size() - 1;
i > 0 && prevMajors.get(i).getMinor() == minor;
i--
) {
for (int i = prevMajors.size() - 1; i > 0 && prevMajors.get(i).getMinor() == minor; i--) {
wireCompat.add(prevMajors.get(i));
}
wireCompat.addAll(groupByMajor.get(currentVersion.getMajor()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,19 @@ public void setFiles(FileTree files) {
}

@InputFiles
public FileTree getFiles() { return files; }
public FileTree getFiles() {
return files;
}

public void setHeaderLine(String headerLine) {
this.headerLine = headerLine;
}

@Input
@Optional
public String getHeaderLine() { return headerLine; }
public String getHeaderLine() {
return headerLine;
}

public void setTarget(File target) {
this.target = target;
Expand All @@ -77,20 +81,15 @@ public File getTarget() {
@TaskAction
public void concatFiles() throws IOException {
if (getHeaderLine() != null) {
Files.write(
getTarget().toPath(),
(getHeaderLine() + '\n').getBytes(StandardCharsets.UTF_8)
);
Files.write(getTarget().toPath(), (getHeaderLine() + '\n').getBytes(StandardCharsets.UTF_8));
}

// To remove duplicate lines
LinkedHashSet<String> uniqueLines = new LinkedHashSet<>();
for (File f : getFiles()) {
uniqueLines.addAll(Files.readAllLines(f.toPath(), StandardCharsets.UTF_8));
}
Files.write(
getTarget().toPath(), uniqueLines, StandardCharsets.UTF_8, StandardOpenOption.APPEND
);
Files.write(getTarget().toPath(), uniqueLines, StandardCharsets.UTF_8, StandardOpenOption.APPEND);
}

}
Loading

0 comments on commit b62a2b7

Please sign in to comment.