8062504: javadoc Start does not close file managers that it opens
Reviewed-by: ksrini
--- 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);