uschindler commented on code in PR #14633: URL: https://github.com/apache/lucene/pull/14633#discussion_r2081556092
########## lucene/backward-codecs/src/java/org/apache/lucene/backward_codecs/lucene101/Lucene101PostingsReader.java: ########## @@ -120,23 +119,21 @@ public Lucene101PostingsReader(SegmentReadState state) throws IOException { expectedPayFileLength = -1; } CodecUtil.checkFooter(metaIn, null); - success = true; } catch (Throwable t) { - if (metaIn != null) { - CodecUtil.checkFooter(metaIn, t); - throw new AssertionError("unreachable"); - } else { - throw t; - } - } finally { - if (success) { - metaIn.close(); - } else { - IOUtils.closeWhileHandlingException(metaIn); + try { + if (metaIn != null) { + CodecUtil.checkFooter(metaIn, t); + throw new AssertionError("unreachable"); + } else { + throw t; + } + } catch (Throwable ct) { + IOUtils.closeWhileSuppressingExceptions(ct, metaIn); + throw ct; } } + metaIn.close(); Review Comment: Can we not use try with resources here? ########## lucene/core/src/java/org/apache/lucene/util/IOUtils.java: ########## @@ -247,6 +308,33 @@ public static void deleteFilesIgnoringExceptions(Collection<? extends Path> file } } + /** + * Deletes all given files, ignoring all thrown Throwables. + * + * <p>Some of the files may be null, if so they are ignored. + */ + public static void deleteFilesSuppressingExceptions(Throwable ex, Path... files) { + deleteFilesSuppressingExceptions(ex, Arrays.asList(files)); + } + + /** + * Deletes all given files, ignoring all thrown Throwables. Review Comment: Add to docs that the suppressed exceptions are recorded in the given Throwable. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org