diff --git a/buildSrc/src/main/java/org/springframework/boot/build/testing/TestFailuresPlugin.java b/buildSrc/src/main/java/org/springframework/boot/build/testing/TestFailuresPlugin.java index 01081706c5..806e563b1b 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/testing/TestFailuresPlugin.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/testing/TestFailuresPlugin.java @@ -56,7 +56,7 @@ public class TestFailuresPlugin implements Plugin { private final class FailureRecordingTestListener implements TestListener { - private List failures = new ArrayList<>(); + private final List failures = new ArrayList<>(); private final TestResultsExtension testResults; @@ -106,7 +106,7 @@ public class TestFailuresPlugin implements Plugin { public int compareTo(TestFailure other) { int comparison = this.descriptor.getClassName().compareTo(other.descriptor.getClassName()); if (comparison == 0) { - comparison = this.descriptor.getName().compareTo(other.descriptor.getClassName()); + comparison = this.descriptor.getName().compareTo(other.descriptor.getName()); } return comparison; } diff --git a/buildSrc/src/test/java/org/springframework/boot/build/testing/TestFailuresPluginIntegrationTests.java b/buildSrc/src/test/java/org/springframework/boot/build/testing/TestFailuresPluginIntegrationTests.java index 1f8af25a29..94313405ab 100644 --- a/buildSrc/src/test/java/org/springframework/boot/build/testing/TestFailuresPluginIntegrationTests.java +++ b/buildSrc/src/test/java/org/springframework/boot/build/testing/TestFailuresPluginIntegrationTests.java @@ -22,9 +22,9 @@ import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.io.StringReader; -import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; +import java.util.stream.Collectors; import org.gradle.testkit.runner.BuildResult; import org.gradle.testkit.runner.GradleRunner; @@ -169,17 +169,12 @@ class TestFailuresPluginIntegrationTests { } private List readLines(String output) { - List lines = new ArrayList<>(); try (BufferedReader reader = new BufferedReader(new StringReader(output))) { - String line; - while ((line = reader.readLine()) != null) { - lines.add(line); - } + return reader.lines().collect(Collectors.toList()); } catch (IOException ex) { throw new RuntimeException(ex); } - return lines; } }