8156911: JShell: file manager should be closed
authorjlahoda
Mon, 22 Aug 2016 18:19:31 +0200
changeset 40517 611ca58fca75
parent 40516 9e0e107c39dd
child 40518 eb9dfc05f8c6
8156911: JShell: file manager should be closed Summary: Properly closing the file manager when it is being thrown away on error. Reviewed-by: rfield
langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java	Mon Aug 22 09:12:11 2016 -0700
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java	Mon Aug 22 18:19:31 2016 +0200
@@ -1196,6 +1196,11 @@
                     fm.setLocationFromPaths(StandardLocation.SOURCE_PATH, sources);
                 } catch (IOException ex) {
                     proc.debug(ex, "SourceCodeAnalysisImpl.SourceCache.<init>(...)");
+                    try {
+                        fm.close();
+                    } catch (IOException closeEx) {
+                        proc.debug(closeEx, "SourceCodeAnalysisImpl.SourceCache.close()");
+                    }
                     fm = null;
                 }
                 this.fm = fm;