Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.time.Duration;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
Expand Down Expand Up @@ -708,12 +707,12 @@ HttpResponse.BodySubscriber<T> ignoreBody(HttpResponse.ResponseInfo hdrs) {
if (s == null) {
// s can be null if an exception occurred
// asynchronously while sending the preface.
Throwable t = c.getRecordedCause();
final Throwable terminationException = c.getTerminationException()
.orElse(null);
IOException ioe;
if (t != null) {
if (!cached)
c.close();
Comment on lines -714 to -715
Copy link
Contributor

Choose a reason for hiding this comment

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

We remove the if (!cached) c.close() logic. Where do we restore this functionality? If not, why not?

Copy link
Member

Choose a reason for hiding this comment

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

If the terminationException is not null the connection is already closed (or being closed by another thread) so there's no need to call close() again.

ioe = new IOException("Can't get stream 1: " + t, t);
if (terminationException != null) {
ioe = new IOException("Can't get stream 1: " + terminationException,
terminationException);
} else {
ioe = new IOException("Can't get stream 1");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -25,7 +25,6 @@

package jdk.internal.net.http;

import java.io.EOFException;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.Base64;
Expand Down Expand Up @@ -234,11 +233,8 @@ void removeFromPool(Http2Connection c) {
}
}

private EOFException STOPPED;
void stop() {
if (debug.on()) debug.log("stopping");
STOPPED = new EOFException("HTTP/2 client stopped");
STOPPED.setStackTrace(new StackTraceElement[0]);
connectionPoolLock.lock();
try {
stopping = true;
Expand All @@ -253,10 +249,7 @@ void stop() {
private boolean close(Http2Connection h2c) {
// close all streams
try { h2c.closeAllStreams(); } catch (Throwable t) {}
// send GOAWAY
try { h2c.close(); } catch (Throwable t) {}
// attempt graceful shutdown
try { h2c.shutdown(STOPPED); } catch (Throwable t) {}
// double check and close any new streams
try { h2c.closeAllStreams(); } catch (Throwable t) {}
// Allows for use of removeIf in stop()
Expand Down
Loading