diff --git a/test/ProblemList.txt b/test/ProblemList.txt index d848de9b5bb5f7731d7479fedf0e75425c2c6336..70ffffbecf573fc510084d1c499ff4670119ee92 100644 --- a/test/ProblemList.txt +++ b/test/ProblemList.txt @@ -1205,16 +1205,6 @@ java/util/Formatter/Constructors.java generic-all java/util/Locale/Bug4175998Test.java generic-all java/util/Locale/LocaleTest.java generic-all -# Need to be marked othervm, or changed to be samevm safe -java/util/logging/GetGlobalTest.java generic-all -java/util/logging/LoggerSubclass.java generic-all -java/util/logging/LoggingDeadlock.java generic-all -java/util/logging/LoggingDeadlock2.java generic-all -java/util/logging/LoggingMXBeanTest.java generic-all -java/util/logging/LoggingMXBeanTest2.java generic-all -java/util/logging/LoggingNIOChange.java generic-all -java/util/logging/ParentLoggersTest.java generic-all - # Need to be marked othervm, or changed to be samevm safe java/util/WeakHashMap/GCDuringIteration.java generic-all diff --git a/test/java/util/logging/ParentLoggersTest.java b/test/java/util/logging/ParentLoggersTest.java index 2f4a434420a164b5aaf7e7bf59339010ee4545f9..1caacb30a82dacf03b5183a4cd117d72c4d0d946 100644 --- a/test/java/util/logging/ParentLoggersTest.java +++ b/test/java/util/logging/ParentLoggersTest.java @@ -40,7 +40,19 @@ public class ParentLoggersTest { static final String LOGGER_NAME_1 = PARENT_NAME_1 + ".myLogger"; static final String LOGGER_NAME_2 = PARENT_NAME_2 + ".myBar.myLogger"; + static final List initialLoggerNames = new ArrayList(); public static void main(String args[]) throws Exception { + // cache the initial set of loggers before this test begins + // to add any loggers + Enumeration e = logMgr.getLoggerNames(); + List defaultLoggers = getDefaultLoggerNames(); + while (e.hasMoreElements()) { + String logger = e.nextElement(); + if (!defaultLoggers.contains(logger)) { + initialLoggerNames.add(logger); + } + }; + String tstSrc = System.getProperty(TST_SRC_PROP); File fname = new File(tstSrc, LM_PROP_FNAME); String prop = fname.getCanonicalPath(); @@ -56,12 +68,12 @@ public class ParentLoggersTest { } } - public static Vector getDefaultLoggerNames() { - Vector expectedLoggerNames = new Vector(0); + public static List getDefaultLoggerNames() { + List expectedLoggerNames = new ArrayList(); // LogManager always creates two loggers: - expectedLoggerNames.addElement(""); // root logger: "" - expectedLoggerNames.addElement("global"); // global logger: "global" + expectedLoggerNames.add(""); // root logger: "" + expectedLoggerNames.add("global"); // global logger: "global" return expectedLoggerNames; } @@ -71,7 +83,7 @@ public class ParentLoggersTest { */ public static boolean checkLoggers() { String failMsg = "# checkLoggers: getLoggerNames() returned unexpected loggers"; - Vector expectedLoggerNames = getDefaultLoggerNames(); + Vector expectedLoggerNames = new Vector(getDefaultLoggerNames()); // Create the logger LOGGER_NAME_1 Logger logger1 = Logger.getLogger(LOGGER_NAME_1); @@ -83,18 +95,23 @@ public class ParentLoggersTest { expectedLoggerNames.addElement(PARENT_NAME_2); expectedLoggerNames.addElement(LOGGER_NAME_2); - Enumeration returnedLoggersEnum = logMgr.getLoggerNames(); - Vector returnedLoggerNames = new Vector(0); + Enumeration returnedLoggersEnum = logMgr.getLoggerNames(); + Vector returnedLoggerNames = new Vector(0); while (returnedLoggersEnum.hasMoreElements()) { - returnedLoggerNames.addElement(returnedLoggersEnum.nextElement()); + String logger = returnedLoggersEnum.nextElement(); + if (!initialLoggerNames.contains(logger)) { + // filter out the loggers that have been added before this test runs + returnedLoggerNames.addElement(logger); + } + }; return checkNames(expectedLoggerNames, returnedLoggerNames, failMsg); } // Returns boolean values: PASSED or FAILED - private static boolean checkNames(Vector expNames, - Vector retNames, + private static boolean checkNames(Vector expNames, + Vector retNames, String failMsg) { boolean status = PASSED; @@ -123,8 +140,8 @@ public class ParentLoggersTest { return status; } - private static void printFailMsg(Vector expNames, - Vector retNames, + private static void printFailMsg(Vector expNames, + Vector retNames, String failMsg) { out.println(); out.println(failMsg);