8033542: test/java/util/logging/SimpleLogManager might let Loggers be gc'ed too early

Fix another case of potentially premature Logger garbage collection in tests.

Reviewed-by: mchung
This commit is contained in:
Daniel Fuchs 2014-02-05 17:56:04 +01:00
parent 8ca6ca944b
commit 11c56780a4

View File

@ -98,16 +98,14 @@ public class SimpleLogManager extends CustomLogManager {
return false;
}
CustomLogger newLogger = new CustomLogger(logger);
super.addLogger(newLogger);
return true;
return super.addLogger(newLogger);
}
public class CustomLogger extends Logger {
final Logger keepRef; // keep a strong reference to avoid GC.
CustomLogger(Logger logger) {
super(logger.getName(), logger.getResourceBundleName());
}
CustomLogger(String name) {
super(name, null);
keepRef = logger;
}
}
}