changeset 91:0171aa52c5df

CODETOOLS-7175037 logfile.log file handle not released after closing workdirectory
author afedorch
date Wed, 10 Aug 2016 17:18:30 +0300
parents 3550bb82fc7f
children 82261c0313af
files src/com/sun/javatest/TestResultCache.java
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/com/sun/javatest/TestResultCache.java	Wed Aug 10 17:16:48 2016 +0300
+++ b/src/com/sun/javatest/TestResultCache.java	Wed Aug 10 17:18:30 2016 +0300
@@ -34,9 +34,12 @@
 import java.util.Map;
 import java.util.TreeMap;
 
+import com.sun.javatest.logging.WorkDirLogHandler;
 import com.sun.javatest.util.Debug;
 import com.sun.javatest.util.Fifo;
 import com.sun.javatest.util.I18NResourceBundle;
+
+import java.util.logging.Handler;
 import java.util.logging.Logger;
 
 /**
@@ -448,6 +451,22 @@
             // ignore
         }
 
+        try {
+            if (workDir != null && workDir.getTestSuite() != null) {
+                Logger log = workDir.getTestSuite().getLog(workDir, i18n.getString("core.log.name"));
+                if (log != null && log.getHandlers() != null) {
+                    for (Handler handler : log.getHandlers()) {
+                        if (handler instanceof WorkDirLogHandler) {
+                            ((WorkDirLogHandler) handler).close();
+                        }
+                    }
+                }
+            }
+        }
+        catch (TestSuite.NoSuchLogFault noSuchLogFault) {
+            //nothing to do
+        }
+
         // important to avoid memory leak !!!
         try {
             if (shutdownHandler != null) {