./test/java/util/logging/LoggingMXBeanTest.java

Print this page
rev 5910 : 7146552: java/util/logging/LoggingMXBeanTest.java failing intermittently
Summary: tests failing because Loggers get gc'd due to weak references; make static
Reviewed-by: duke

*** 1,7 **** /* ! * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 41,50 **** --- 41,52 ---- LoggingMXBean mBean; ObjectName objectName = null; static String LOGGER_NAME_1 = "com.sun.management.Logger1"; static String LOGGER_NAME_2 = "com.sun.management.Logger2"; + static Logger logger1; + static Logger logger2; public LoggingMXBeanTest() throws Exception { /* * Create the MBeanServeri, register the LoggingMXBean
*** 129,140 **** System.out.println(""); System.out.println( "*******************************" ); System.out.println( "*********** Phase 3 ***********" ); System.out.println( "*******************************" ); System.out.println( " Create and test new Loggers" ); ! Logger logger1 = Logger.getLogger( LOGGER_NAME_1 ); ! Logger logger2 = Logger.getLogger( LOGGER_NAME_2 ); // check that Level object are returned properly try { list = (String[]) mbs.getAttribute( objectName, "LoggerNames" ); } --- 131,142 ---- System.out.println(""); System.out.println( "*******************************" ); System.out.println( "*********** Phase 3 ***********" ); System.out.println( "*******************************" ); System.out.println( " Create and test new Loggers" ); ! logger1 = Logger.getLogger( LOGGER_NAME_1 ); ! logger2 = Logger.getLogger( LOGGER_NAME_2 ); // check that Level object are returned properly try { list = (String[]) mbs.getAttribute( objectName, "LoggerNames" ); }