test/java/util/logging/AnonLoggerWeakRefLeak.java
Print this page
*** 21,48 ****
* questions.
*/
import java.util.logging.*;
! public class AnonLoggerWeakRefLeak {
! public static int DEFAULT_LOOP_TIME = 60; // 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: AnonLoggerWeakRefLeak [seconds]");
- System.exit(1);
}
}
long count = 0;
long now = 0;
--- 21,56 ----
* questions.
*/
import java.util.logging.*;
! public class AnonLoggerWeakRefLeak 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 this particular WeakReference leak, the count
! // was always observed to be increasing so if we get a decreasing
! // count, then the leak is 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 AnonLoggerWeakRefLeak 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;
long now = 0;
*** 71,76 ****
--- 79,92 ----
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);
+ }
}