8303481: CancelRequestTest assertTrue failing with AssertionError due to java.util.concurrent.CompletionException: java.io.EOFException: EOF reached while reading

Reviewed-by: jpai, djelinski
This commit is contained in:
Daniel Fuchs 2023-03-03 13:18:23 +00:00
parent 8bf084ced9
commit cbdc7a6f88
3 changed files with 18 additions and 4 deletions
src/java.net.http/share/classes/jdk/internal/net/http/frame
test/jdk/java/net/httpclient/lib/jdk/httpclient/test/lib/http2

@ -80,4 +80,8 @@ public class OutgoingHeaders<T> extends Http2Frame {
return system;
}
@Override
public String toString() {
return "OutgoingHeaders()";
}
}

@ -828,7 +828,10 @@ public class Http2TestServerConnection {
throw new IOException("Unexpected frame");
}
} else {
q.put(frame);
if (!q.putIfOpen(frame)) {
System.err.printf("Stream %s is closed: dropping %s%n",
stream, frame);
}
}
}
}

@ -58,17 +58,24 @@ public class Queue<T> implements ExceptionallyCloseable {
return closing;
}
public synchronized boolean isOpen() {
return !closed && !closing;
}
public synchronized void put(T obj) throws IOException {
Objects.requireNonNull(obj);
if (closed || closing) {
if (!putIfOpen(obj)) {
throw new IOException("stream closed");
}
}
public synchronized boolean putIfOpen(T obj) {
Objects.requireNonNull(obj);
if (!isOpen()) return false;
q.add(obj);
if (waiters > 0) {
notifyAll();
}
return true;
}
// Other close() variants are immediate and abortive