Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8255124: KeepAliveStreamCleaner may crash with java.lang.IllegalMonit…
…orStateException: current thread is not owner

Reviewed-by: alanb, chegar, dfuchs
  • Loading branch information
lahodaj committed Oct 22, 2020
1 parent 299e115 commit 211bb62
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Expand Up @@ -30,6 +30,7 @@
import sun.net.NetProperties;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

Expand Down Expand Up @@ -115,7 +116,7 @@ public void run()
long before = System.currentTimeMillis();
long timeout = TIMEOUT;
while ((kace = poll()) == null) {
waiter.wait(timeout);
waiter.await(timeout, TimeUnit.MILLISECONDS);

long after = System.currentTimeMillis();
long elapsed = after - before;
Expand Down
11 changes: 10 additions & 1 deletion test/jdk/sun/net/www/http/KeepAliveCache/B5045306.java
Expand Up @@ -23,7 +23,7 @@

/*
* @test
* @bug 5045306 6356004 6993490
* @bug 5045306 6356004 6993490 8255124
* @modules java.base/sun.net.www
* java.management
* @library ../../httptest/
Expand All @@ -35,6 +35,8 @@
import java.net.*;
import java.io.*;
import java.lang.management.*;
import java.util.ArrayList;
import java.util.List;

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

public static void clientHttpCalls() {
List<Throwable> uncaught = new ArrayList<>();
Thread.setDefaultUncaughtExceptionHandler((t, ex) -> {
uncaught.add(ex);
});
try {
System.out.println("http server listen on: " + server.getLocalPort());
String hostAddr = InetAddress.getLocalHost().getHostAddress();
Expand Down Expand Up @@ -133,6 +139,9 @@ public static void clientHttpCalls() {
} finally {
server.terminate();
}
if (!uncaught.isEmpty()) {
throw new RuntimeException("Unhandled exception:", uncaught.get(0));
}
}
}

Expand Down

1 comment on commit 211bb62

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on 211bb62 Oct 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.