@@ -2803,40 +2803,37 @@ public static Path walkFileTree(Path start,
28032803 try (FileTreeWalker walker = new FileTreeWalker (options , maxDepth )) {
28042804 FileTreeWalker .Event ev = walker .walk (start );
28052805 do {
2806- FileVisitResult result ;
2807- switch (ev .type ()) {
2808- case ENTRY :
2806+ FileVisitResult result = switch (ev .type ()) {
2807+ case ENTRY -> {
28092808 IOException ioe = ev .ioeException ();
28102809 if (ioe == null ) {
28112810 assert ev .attributes () != null ;
2812- result = visitor .visitFile (ev .file (), ev .attributes ());
2811+ yield visitor .visitFile (ev .file (), ev .attributes ());
28132812 } else {
2814- result = visitor .visitFileFailed (ev .file (), ioe );
2813+ yield visitor .visitFileFailed (ev .file (), ioe );
28152814 }
2816- break ;
2817-
2818- case START_DIRECTORY :
2819- result = visitor .preVisitDirectory (ev .file (), ev .attributes ());
2815+ }
2816+ case START_DIRECTORY -> {
2817+ var res = visitor .preVisitDirectory (ev .file (), ev .attributes ());
28202818
28212819 // if SKIP_SIBLINGS and SKIP_SUBTREE is returned then
28222820 // there shouldn't be any more events for the current
28232821 // directory.
2824- if (result == FileVisitResult .SKIP_SUBTREE ||
2825- result == FileVisitResult .SKIP_SIBLINGS )
2822+ if (res == FileVisitResult .SKIP_SUBTREE ||
2823+ res == FileVisitResult .SKIP_SIBLINGS )
28262824 walker .pop ();
2827- break ;
2828-
2829- case END_DIRECTORY :
2830- result = visitor .postVisitDirectory (ev .file (), ev .ioeException ());
2825+ yield res ;
2826+ }
2827+ case END_DIRECTORY -> {
2828+ var res = visitor .postVisitDirectory (ev .file (), ev .ioeException ());
28312829
28322830 // SKIP_SIBLINGS is a no-op for postVisitDirectory
2833- if (result == FileVisitResult .SKIP_SIBLINGS )
2834- result = FileVisitResult .CONTINUE ;
2835- break ;
2836-
2837- default :
2838- throw new AssertionError ("Should not get here" );
2839- }
2831+ if (res == FileVisitResult .SKIP_SIBLINGS )
2832+ res = FileVisitResult .CONTINUE ;
2833+ yield res ;
2834+ }
2835+ default -> throw new AssertionError ("Should not get here" );
2836+ };
28402837
28412838 if (Objects .requireNonNull (result ) != FileVisitResult .CONTINUE ) {
28422839 if (result == FileVisitResult .TERMINATE ) {
0 commit comments