8299419: Thread.sleep(millis) may throw OOME
Reviewed-by: alanb
This commit is contained in:
parent
591aa7c5c7
commit
b0cff6b528
@ -457,19 +457,20 @@ public class Thread implements Runnable {
|
||||
* Called before sleeping to create a jdk.ThreadSleep event.
|
||||
*/
|
||||
private static ThreadSleepEvent beforeSleep(long nanos) {
|
||||
ThreadSleepEvent event = null;
|
||||
if (ThreadSleepEvent.isTurnedOn()) {
|
||||
try {
|
||||
event = new ThreadSleepEvent();
|
||||
try {
|
||||
ThreadSleepEvent event = new ThreadSleepEvent();
|
||||
if (event.isEnabled()) {
|
||||
event.time = nanos;
|
||||
event.begin();
|
||||
} catch (OutOfMemoryError e) {
|
||||
event = null;
|
||||
return event;
|
||||
}
|
||||
} catch (OutOfMemoryError e) {
|
||||
// ignore
|
||||
}
|
||||
return event;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called after sleeping to commit the jdk.ThreadSleep event.
|
||||
*/
|
||||
|
@ -30,14 +30,5 @@ package jdk.internal.event;
|
||||
*/
|
||||
|
||||
public final class ThreadSleepEvent extends Event {
|
||||
private static final ThreadSleepEvent EVENT = new ThreadSleepEvent();
|
||||
|
||||
/**
|
||||
* Returns {@code true} if event is enabled, {@code false} otherwise.
|
||||
*/
|
||||
public static boolean isTurnedOn() {
|
||||
return EVENT.isEnabled();
|
||||
}
|
||||
|
||||
public long time;
|
||||
}
|
||||
|
@ -665,7 +665,6 @@ class SleepingThread extends BaseThread {
|
||||
// jdk.internal.event.ThreadSleepEvent not accessible
|
||||
expectedMethods.add("jdk.internal.event.ThreadSleepEvent.<clinit>");
|
||||
expectedMethods.add("jdk.internal.event.ThreadSleepEvent.isEnabled");
|
||||
expectedMethods.add("jdk.internal.event.ThreadSleepEvent.isTurnedOn");
|
||||
expectedMethods.add(SleepingThread.class.getName() + ".run");
|
||||
|
||||
switch (controller.invocationType) {
|
||||
|
@ -42,7 +42,6 @@ public class SleepingThread extends RecursiveMonitoringThread {
|
||||
"java.lang.Thread.afterSleep",
|
||||
"java.util.concurrent.TimeUnit.toNanos",
|
||||
"jdk.internal.event.ThreadSleepEvent.<clinit>",
|
||||
"jdk.internal.event.ThreadSleepEvent.isTurnedOn",
|
||||
"jdk.internal.event.ThreadSleepEvent.isEnabled",
|
||||
"nsk.monitoring.share.thread.SleepingThread.runInside"
|
||||
};
|
||||
|
@ -151,7 +151,6 @@ public class strace001 {
|
||||
"java.util.concurrent.TimeUnit.toNanos",
|
||||
"jdk.internal.event.ThreadSleepEvent.<clinit>",
|
||||
"jdk.internal.event.ThreadSleepEvent.<init>",
|
||||
"jdk.internal.event.ThreadSleepEvent.isTurnedOn",
|
||||
"jdk.internal.event.ThreadSleepEvent.isEnabled"
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user