On Wed, 2 Jun 2021 09:13:44 GMT, Chris Hegarty <che...@openjdk.org> wrote:
>> Patrick Concannon has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8268056: Reverted changes to URLDecoder; reformatted change to FileTime > > src/java.base/share/classes/java/nio/file/Files.java line 2832: > >> 2830: result = FileVisitResult.CONTINUE; >> 2831: } >> 2832: default -> throw new AssertionError("Should not >> get here"); > > This is subjective, and we're still finding our way with how best to > construct some of the more complex switch expressions. > > Where possible, I think it is best to remove assignments from the individual > case branches. The use of `yield` makes it very clear what is going on, and > ensures that each case branch, well... yields something. So how about: > > > FileVisitResult result = switch (ev.type()) { > case ENTRY -> { > IOException ioe = ev.ioeException(); > if (ioe == null) { > assert ev.attributes() != null; > yield visitor.visitFile(ev.file(), ev.attributes()); > } else { > yield visitor.visitFileFailed(ev.file(), ioe); > } > } > case START_DIRECTORY -> { > var r = visitor.preVisitDirectory(ev.file(), ev.attributes()); > > // if SKIP_SIBLINGS and SKIP_SUBTREE is returned then > // there shouldn't be any more events for the current > // directory. > if (r == FileVisitResult.SKIP_SUBTREE || > r == FileVisitResult.SKIP_SIBLINGS) > walker.pop(); > yield r; > } > case END_DIRECTORY -> { > var r = visitor.postVisitDirectory(ev.file(), ev.ioeException()); > // SKIP_SIBLINGS is a no-op for postVisitDirectory > if (r == FileVisitResult.SKIP_SIBLINGS) > r = FileVisitResult.CONTINUE; > yield r; > } > default -> throw new AssertionError("Should not get here"); > }; OK. I've made that change now. See 433b02a ------------- PR: https://git.openjdk.java.net/jdk/pull/4285