# HG changeset patch # User mchung # Date 1276756061 25200 # Node ID c3ddaebe216bca339fa81c4f22eb8a754c95e952 # Parent ea99d72d3c1991d49e6cde4f136c59bab770dd6b 6961408: test/java/util/logging/ParentLoggersTest.java fails in samevm mode Summary: Check against the list of loggers added since the test begins to run Reviewed-by: dcubed diff -r ea99d72d3c19 -r c3ddaebe216b jdk/test/ProblemList.txt --- a/jdk/test/ProblemList.txt Thu Jun 17 13:46:15 2010 +0800 +++ b/jdk/test/ProblemList.txt Wed Jun 16 23:27:41 2010 -0700 @@ -1206,16 +1206,6 @@ 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 # Possible missing input stream close()? Causes samevm issues on windows diff -r ea99d72d3c19 -r c3ddaebe216b jdk/test/java/util/logging/ParentLoggersTest.java --- a/jdk/test/java/util/logging/ParentLoggersTest.java Thu Jun 17 13:46:15 2010 +0800 +++ b/jdk/test/java/util/logging/ParentLoggersTest.java Wed Jun 16 23:27:41 2010 -0700 @@ -40,7 +40,19 @@ 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 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 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 @@ 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 @@ 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);