@@ -47,19 +47,8 @@ public class FlakyTestReporter {
4747 private int errorCount ;
4848 private final List <FlakyTest > flakyTests = new ArrayList <>();
4949
50- private static class FlakyTest {
51- final String testClassName ;
52- final String testName ;
53- final String timestamp ;
54- final String message ;
55-
56- FlakyTest (String testClassName , String testName , String timestamp , String message ) {
57- this .testClassName = testClassName ;
58- this .testName = testName ;
59- this .timestamp = timestamp ;
60- this .message = message ;
61- }
62- }
50+ private record FlakyTest (
51+ String testClassName , String testName , String timestamp , String message ) {}
6352
6453 private void addFlakyTest (
6554 String testClassName , String testName , String timestamp , String message ) {
@@ -160,6 +149,15 @@ private static String getAttributeValue(Node node, String attributeName) {
160149 return value != null ? value .getNodeValue () : null ;
161150 }
162151
152+ private static class BaseFileVisitor <T > extends SimpleFileVisitor <T > {
153+ @ Override
154+ public FileVisitResult visitFileFailed (T file , IOException exception ) {
155+ System .err .println ("Failed to visit " + file .toString ());
156+ exception .printStackTrace ();
157+ return CONTINUE ;
158+ }
159+ }
160+
163161 private void scanTestResults (Path buildDir ) throws IOException {
164162 Path testResults = buildDir .resolve ("test-results" );
165163 if (!Files .exists (testResults )) {
@@ -168,7 +166,7 @@ private void scanTestResults(Path buildDir) throws IOException {
168166
169167 Files .walkFileTree (
170168 testResults ,
171- new SimpleFileVisitor <>() {
169+ new BaseFileVisitor <>() {
172170 @ Override
173171 public FileVisitResult visitFile (Path file , BasicFileAttributes attrs ) {
174172 String name = file .getFileName ().toString ();
@@ -178,21 +176,14 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
178176
179177 return CONTINUE ;
180178 }
181-
182- @ Override
183- public FileVisitResult visitFileFailed (Path file , IOException exception ) {
184- System .err .println ("Failed to visit " + file .toString ());
185- exception .printStackTrace ();
186- return CONTINUE ;
187- }
188179 });
189180 }
190181
191182 private static FlakyTestReporter scan (Path path ) throws IOException {
192183 FlakyTestReporter reporter = new FlakyTestReporter ();
193184 Files .walkFileTree (
194185 path ,
195- new SimpleFileVisitor <>() {
186+ new BaseFileVisitor <>() {
196187 @ Override
197188 public FileVisitResult preVisitDirectory (Path dir , BasicFileAttributes attrs )
198189 throws IOException {
0 commit comments