Skip to content

Commit 211bb62

Browse files
committed
8255124: KeepAliveStreamCleaner may crash with java.lang.IllegalMonitorStateException: current thread is not owner
Reviewed-by: alanb, chegar, dfuchs
1 parent 299e115 commit 211bb62

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/java.base/share/classes/sun/net/www/http/KeepAliveStreamCleaner.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import sun.net.NetProperties;
3131
import java.security.AccessController;
3232
import java.security.PrivilegedAction;
33+
import java.util.concurrent.TimeUnit;
3334
import java.util.concurrent.locks.Condition;
3435
import java.util.concurrent.locks.ReentrantLock;
3536

@@ -115,7 +116,7 @@ public void run()
115116
long before = System.currentTimeMillis();
116117
long timeout = TIMEOUT;
117118
while ((kace = poll()) == null) {
118-
waiter.wait(timeout);
119+
waiter.await(timeout, TimeUnit.MILLISECONDS);
119120

120121
long after = System.currentTimeMillis();
121122
long elapsed = after - before;

test/jdk/sun/net/www/http/KeepAliveCache/B5045306.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
/*
2525
* @test
26-
* @bug 5045306 6356004 6993490
26+
* @bug 5045306 6356004 6993490 8255124
2727
* @modules java.base/sun.net.www
2828
* java.management
2929
* @library ../../httptest/
@@ -35,6 +35,8 @@
3535
import java.net.*;
3636
import java.io.*;
3737
import java.lang.management.*;
38+
import java.util.ArrayList;
39+
import java.util.List;
3840

3941
/* Part 1:
4042
* The http client makes a connection to a URL whos content contains a lot of
@@ -69,6 +71,10 @@ public static void startHttpServer() {
6971
}
7072

7173
public static void clientHttpCalls() {
74+
List<Throwable> uncaught = new ArrayList<>();
75+
Thread.setDefaultUncaughtExceptionHandler((t, ex) -> {
76+
uncaught.add(ex);
77+
});
7278
try {
7379
System.out.println("http server listen on: " + server.getLocalPort());
7480
String hostAddr = InetAddress.getLocalHost().getHostAddress();
@@ -133,6 +139,9 @@ public static void clientHttpCalls() {
133139
} finally {
134140
server.terminate();
135141
}
142+
if (!uncaught.isEmpty()) {
143+
throw new RuntimeException("Unhandled exception:", uncaught.get(0));
144+
}
136145
}
137146
}
138147

0 commit comments

Comments
 (0)