File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
src/java.net.http/share/classes/jdk/internal/net/http
test/jdk/java/net/httpclient/http2 Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 46
46
import java .util .concurrent .Flow .Subscription ;
47
47
import java .util .concurrent .atomic .AtomicInteger ;
48
48
import java .util .concurrent .atomic .AtomicReference ;
49
+ import java .util .concurrent .locks .Lock ;
50
+ import java .util .concurrent .locks .ReentrantLock ;
49
51
import java .util .function .BiPredicate ;
50
52
import java .net .http .HttpClient ;
51
53
import java .net .http .HttpHeaders ;
@@ -431,13 +433,10 @@ private void receiveDataFrame(DataFrame df) {
431
433
// is OK.
432
434
private void pushDataFrame (int len , DataFrame df ) {
433
435
boolean closed = false ;
434
- stateLock .lock ();
435
- try {
436
+ synchronized (this ) {
436
437
if (!(closed = this .closed )) {
437
438
inputQ .add (df );
438
439
}
439
- } finally {
440
- stateLock .unlock ();
441
440
}
442
441
if (closed && len > 0 ) connection .releaseUnconsumed (df );
443
442
}
Original file line number Diff line number Diff line change 41
41
import java .net .http .HttpClient ;
42
42
import java .net .http .HttpHeaders ;
43
43
import java .net .http .HttpRequest ;
44
+ import java .net .http .HttpRequest .BodyPublishers ;
44
45
import java .net .http .HttpResponse ;
45
46
import java .net .http .HttpResponse .BodyHandlers ;
46
47
import java .nio .charset .StandardCharsets ;
@@ -296,10 +297,14 @@ public void setup() throws Exception {
296
297
this .https2TestServer .start ();
297
298
298
299
// warmup to eliminate delay due to SSL class loading and initialization.
299
- try (var client = HttpClient .newBuilder ().sslContext (sslContext ).build ()) {
300
- var request = HttpRequest .newBuilder (URI .create (h2Head )).HEAD ().build ();
300
+ HttpClient client = HttpClient .newBuilder ().executor (Executors .newCachedThreadPool ()).sslContext (sslContext ).build ();
301
+ try {
302
+ var request = HttpRequest .newBuilder (URI .create (h2Head )).method ("HEAD" , BodyPublishers .noBody ()).build ();
301
303
var resp = client .send (request , BodyHandlers .discarding ());
302
304
assertEquals (resp .statusCode (), 200 );
305
+ } finally {
306
+ ExecutorService exec = (ExecutorService )client .executor ().get ();
307
+ exec .shutdownNow ();
303
308
}
304
309
}
305
310
You can’t perform that action at this time.
0 commit comments