file manager should be closed

Jonathan Gibbons jonathan.gibbons at oracle.com
Thu May 12 18:23:24 UTC 2016


This is in SourceCodeAnalysisImpl.java.
getStandardFileManager is defined to return a new instance each time it 
is called.   Ideally, each such instance should be closed.  This can be 
done by creating the file manager with try-wirth-resources,


         public SourceCache(AnalyzeTask originalTask) {
             this.originalTask = originalTask;
             List<Path> sources = findSources();
             if (sources.iterator().hasNext()) {
                 StandardJavaFileManager fm = 
compiler.getStandardFileManager(null, null, null);
                 try {
fm.setLocationFromPaths(StandardLocation.SOURCE_PATH, sources);
                 } catch (IOException ex) {
                     proc.debug(ex, 
"SourceCodeAnalysisImpl.SourceCache.<init>(...)");
                     fm = null;
                 }
                 this.fm = fm;
             } else {
                 //don't waste time if there are no sources
                 this.fm = null;
             }
         }


More information about the kulla-dev mailing list