Skip to content

Commit 8252114

Browse files
dfuchpull[bot]
authored andcommitted
8338495: Revert "8336655: java/net/httpclient/DigestEchoClient.java IOException: HTTP/1.1 header parser received no bytes"
Reviewed-by: jpai
1 parent 1364cf8 commit 8252114

File tree

3 files changed

+11
-52
lines changed

3 files changed

+11
-52
lines changed

src/java.net.http/share/classes/jdk/internal/net/http/ConnectionPool.java

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -44,7 +44,6 @@
4444

4545
import jdk.internal.net.http.common.Deadline;
4646
import jdk.internal.net.http.common.FlowTube;
47-
import jdk.internal.net.http.common.Log;
4847
import jdk.internal.net.http.common.Logger;
4948
import jdk.internal.net.http.common.TimeLine;
5049
import jdk.internal.net.http.common.TimeSource;
@@ -493,13 +492,13 @@ void clear() {
493492

494493
// Remove a connection from the pool.
495494
// should only be called while holding the ConnectionPool stateLock.
496-
private boolean removeFromPool(HttpConnection c) {
495+
private void removeFromPool(HttpConnection c) {
497496
assert stateLock.isHeldByCurrentThread();
498497
if (c instanceof PlainHttpConnection) {
499-
return removeFromPool(c, plainPool);
498+
removeFromPool(c, plainPool);
500499
} else {
501500
assert c.isSecure() : "connection " + c + " is not secure!";
502-
return removeFromPool(c, sslPool);
501+
removeFromPool(c, sslPool);
503502
}
504503
}
505504

@@ -530,29 +529,13 @@ void cleanup(HttpConnection c, Throwable error) {
530529
debug.log("%s : ConnectionPool.cleanup(%s)",
531530
String.valueOf(c.getConnectionFlow()), error);
532531
stateLock.lock();
533-
boolean removed;
534532
try {
535-
removed = removeFromPool(c);
533+
removeFromPool(c);
536534
expiryList.remove(c);
537535
} finally {
538536
stateLock.unlock();
539537
}
540-
if (!removed) {
541-
// this should not happen; the cleanup may have consumed
542-
// some data that wasn't supposed to be consumed, so
543-
// the only thing we can do is log it and close the
544-
// connection.
545-
if (Log.errors()) {
546-
Log.logError("WARNING: CleanupTrigger triggered for" +
547-
" a connection not found in the pool: closing {0}", c);
548-
} else if (debug.on()) {
549-
debug.log("WARNING: CleanupTrigger triggered for" +
550-
" a connection not found in the pool: closing %s", c);
551-
}
552-
c.close(new IOException("Unexpected cleanup triggered for non pooled connection"));
553-
} else {
554-
c.close();
555-
}
538+
c.close();
556539
}
557540

558541
/**
@@ -566,7 +549,6 @@ private final class CleanupTrigger implements
566549

567550
private final HttpConnection connection;
568551
private volatile boolean done;
569-
private volatile boolean dropped;
570552

571553
public CleanupTrigger(HttpConnection connection) {
572554
this.connection = connection;
@@ -584,7 +566,6 @@ private void triggerCleanup(Throwable error) {
584566

585567
@Override
586568
public void onSubscribe(Flow.Subscription subscription) {
587-
if (dropped || done) return;
588569
subscription.request(1);
589570
}
590571
@Override
@@ -605,10 +586,5 @@ public void subscribe(Flow.Subscriber<? super List<ByteBuffer>> subscriber) {
605586
public String toString() {
606587
return "CleanupTrigger(" + connection.getConnectionFlow() + ")";
607588
}
608-
609-
@Override
610-
public void dropSubscription() {
611-
dropped = true;
612-
}
613589
}
614590
}

src/java.net.http/share/classes/jdk/internal/net/http/SocketTube.java

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -573,8 +573,6 @@ public void subscribe(Flow.Subscriber<? super List<ByteBuffer>> s) {
573573
debug.log("read publisher: dropping pending subscriber: "
574574
+ previous.subscriber);
575575
previous.errorRef.compareAndSet(null, errorRef.get());
576-
// make sure no data will be routed to the old subscriber.
577-
previous.stopReading();
578576
previous.signalOnSubscribe();
579577
if (subscriptionImpl.completed) {
580578
previous.signalCompletion();
@@ -608,7 +606,6 @@ final class ReadSubscription implements Flow.Subscription {
608606
volatile boolean subscribed;
609607
volatile boolean cancelled;
610608
volatile boolean completed;
611-
volatile boolean stopped;
612609

613610
public ReadSubscription(InternalReadSubscription impl,
614611
TubeSubscriber subscriber) {
@@ -626,11 +623,11 @@ public void cancel() {
626623

627624
@Override
628625
public void request(long n) {
629-
if (!cancelled && !stopped) {
626+
if (!cancelled) {
630627
impl.request(n);
631628
} else {
632629
if (debug.on())
633-
debug.log("subscription stopped or cancelled, ignoring request %d", n);
630+
debug.log("subscription cancelled, ignoring request %d", n);
634631
}
635632
}
636633

@@ -664,20 +661,6 @@ void signalOnSubscribe() {
664661
signalCompletion();
665662
}
666663
}
667-
668-
/**
669-
* Called when switching subscriber on the {@link InternalReadSubscription}.
670-
* This subscriber is the old subscriber. Demand on the internal
671-
* subscription will be reset and reading will be paused until the
672-
* new subscriber is subscribed.
673-
* This should ensure that no data is routed to this subscriber
674-
* until the new subscriber is subscribed.
675-
*/
676-
void stopReading() {
677-
stopped = true;
678-
impl.demand.reset();
679-
impl.pauseReadEvent();
680-
}
681664
}
682665

683666
final class InternalReadSubscription implements Flow.Subscription {

test/jdk/java/net/httpclient/DigestEchoClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -64,7 +64,7 @@
6464
* @test
6565
* @summary this test verifies that a client may provides authorization
6666
* headers directly when connecting with a server.
67-
* @bug 8087112 8336655
67+
* @bug 8087112
6868
* @library /test/lib /test/jdk/java/net/httpclient/lib
6969
* @build jdk.httpclient.test.lib.common.HttpServerAdapters jdk.test.lib.net.SimpleSSLContext
7070
* DigestEchoServer ReferenceTracker DigestEchoClient

0 commit comments

Comments
 (0)