test/java/util/logging/LoggerWeakRefLeak.java
Print this page
*** 21,51 ****
* questions.
*/
import java.util.logging.*;
! public class LoggerWeakRefLeak {
! // AnonLoggerWeakRefLeak checks for one weak reference leak.
! // LoggerWeakRefLeak checks for two weak reference leaks so
! // this test runs twice as long, by default.
public static int DEFAULT_LOOP_TIME = 120; // time is in seconds
! public static void main(String[] args) {
int loop_time = 0;
int max_loop_time = DEFAULT_LOOP_TIME;
! if (args.length == 0) {
System.out.println("INFO: using default time of "
+ max_loop_time + " seconds.");
} else {
try {
! max_loop_time = Integer.parseInt(args[0]);
} catch (NumberFormatException nfe) {
! System.err.println("Error: '" + args[0]
+ "': is not a valid seconds value.");
- System.err.println("Usage: LoggerWeakRefLeak [seconds]");
- System.exit(1);
}
}
long count = 0;
int loggerCount = 0;
--- 21,56 ----
* questions.
*/
import java.util.logging.*;
! public class LoggerWeakRefLeak extends SimpleApplication {
! // The test driver script will allow this program to run until we
! // reach DEFAULT_LOOP_TIME or a decrease in instance counts is
! // observed. For these particular WeakReference leaks, the count
! // was always observed to be increasing so if we get a decreasing
! // count, then the leaks are fixed in the bits being tested.
! // Two minutes has been enough time to observe a decrease in
! // fixed bits on overloaded systems, but the test will likely
! // finish more quickly.
public static int DEFAULT_LOOP_TIME = 120; // time is in seconds
! // execute the LoggerWeakRefLeak app work
! public void doMyAppWork(String[] args) throws Exception {
int loop_time = 0;
int max_loop_time = DEFAULT_LOOP_TIME;
! // args[0] is the port-file
! if (args.length < 2) {
System.out.println("INFO: using default time of "
+ max_loop_time + " seconds.");
} else {
try {
! max_loop_time = Integer.parseInt(args[1]);
} catch (NumberFormatException nfe) {
! throw new RuntimeException("Error: '" + args[1]
+ "': is not a valid seconds value.");
}
}
long count = 0;
int loggerCount = 0;
*** 84,89 ****
--- 89,102 ----
now = System.currentTimeMillis();
}
System.out.println("INFO: final loop count = " + count);
}
+
+ public static void main(String[] args) throws Exception {
+ AnonLoggerWeakRefLeak myApp = new AnonLoggerWeakRefLeak();
+
+ SimpleApplication.setMyApp(myApp);
+
+ SimpleApplication.main(args);
+ }
}