langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/Start.java
changeset 27320 f0739350a62d
parent 25874 83c19f00452c
child 27379 5ae894733e09
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/Start.java	Wed Oct 29 17:25:23 2014 -0700
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/Start.java	Wed Oct 29 18:01:22 2014 -0700
@@ -88,6 +88,9 @@
      */
     private boolean apiMode;
 
+    private JavaFileManager fileManager;
+    private boolean closeFileManagerOnExit;
+
     Start(String programName,
           PrintWriter errWriter,
           PrintWriter warnWriter,
@@ -239,6 +242,12 @@
             messager.error(Messager.NOPOS, "main.fatal.exception");
             failed = true;
         } finally {
+            if (fileManager != null && closeFileManagerOnExit) {
+                try {
+                    fileManager.close();
+                } catch (IOException ignore) {
+                }
+            }
             messager.exitNotice();
             messager.flush();
         }
@@ -270,7 +279,8 @@
         }
 
 
-        JavaFileManager fileManager = context.get(JavaFileManager.class);
+        fileManager = context.get(JavaFileManager.class);
+
         setDocletInvoker(docletClass, fileManager, argv);
 
         compOpts = Options.instance(context);
@@ -333,6 +343,7 @@
         if (fileManager == null) {
             JavacFileManager.preRegister(context);
             fileManager = context.get(JavaFileManager.class);
+            closeFileManagerOnExit = true;
         }
         if (fileManager instanceof BaseFileManager) {
             ((BaseFileManager) fileManager).handleOptions(fileManagerOpts);