mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 03:58:21 +00:00
Do not reset stream when read is interrupted
This commit is contained in:
parent
2504e17096
commit
a8a5415c7b
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2022, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -175,7 +175,7 @@ public final class Http3ServerExchange implements Http2TestExchange {
|
|||||||
}
|
}
|
||||||
serverStream.writer.reset(Http3Error.H3_INTERNAL_ERROR.code());
|
serverStream.writer.reset(Http3Error.H3_INTERNAL_ERROR.code());
|
||||||
}
|
}
|
||||||
is.close(io);
|
is.resetStream(io);
|
||||||
os.closeInternal();
|
os.closeInternal();
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -264,7 +264,7 @@ final class Http3ServerStreamImpl {
|
|||||||
// nothing to do - let the response be sent to the client, but throw an
|
// nothing to do - let the response be sent to the client, but throw an
|
||||||
// exception if `is` is used again.
|
// exception if `is` is used again.
|
||||||
exchangeCF.thenApply(en -> {
|
exchangeCF.thenApply(en -> {
|
||||||
en.is.close(new IOException("stopSendingRequested"));
|
en.is.resetStream(new IOException("stopSendingRequested"));
|
||||||
return en;
|
return en;
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@ -292,7 +292,7 @@ final class Http3ServerStreamImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class RequestBodyInputStream extends InputStream {
|
class RequestBodyInputStream extends InputStream {
|
||||||
// non-null if the QUIC stream was reset, or an exception occurred
|
// non-null if the QUIC stream was reset
|
||||||
volatile IOException error;
|
volatile IOException error;
|
||||||
// true if close() was called
|
// true if close() was called
|
||||||
volatile boolean closed;
|
volatile boolean closed;
|
||||||
@ -301,11 +301,21 @@ final class Http3ServerStreamImpl {
|
|||||||
ByteBuffer current;
|
ByteBuffer current;
|
||||||
|
|
||||||
ByteBuffer current() throws IOException {
|
ByteBuffer current() throws IOException {
|
||||||
|
if (closed) {
|
||||||
|
throw new IOException("Stream is closed");
|
||||||
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
if (current != null && current.hasRemaining()) {
|
if (current != null && current.hasRemaining()) {
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
if (current == QuicStreamReader.EOF) return current;
|
if (current == QuicStreamReader.EOF) {
|
||||||
|
if (closed) {
|
||||||
|
throw new IOException("Stream is closed");
|
||||||
|
}
|
||||||
|
var error = this.error;
|
||||||
|
if (error != null) throw error;
|
||||||
|
return current;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (debug.on())
|
if (debug.on())
|
||||||
debug.log("Taking buffer from queue");
|
debug.log("Taking buffer from queue");
|
||||||
@ -315,26 +325,16 @@ final class Http3ServerStreamImpl {
|
|||||||
var io = new InterruptedIOException();
|
var io = new InterruptedIOException();
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
io.initCause(e);
|
io.initCause(e);
|
||||||
close(io);
|
throw io;
|
||||||
var error = this.error;
|
|
||||||
if (error != null) throw error;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int read() throws IOException {
|
public int read() throws IOException {
|
||||||
if (closed) {
|
|
||||||
throw new IOException("Stream is closed");
|
|
||||||
}
|
|
||||||
ByteBuffer buffer = current();
|
ByteBuffer buffer = current();
|
||||||
if (buffer == QuicStreamReader.EOF) {
|
if (buffer == QuicStreamReader.EOF) {
|
||||||
if (closed) {
|
return -1;
|
||||||
throw new IOException("Stream is closed");
|
|
||||||
}
|
|
||||||
var error = this.error;
|
|
||||||
if (error == null) return -1;
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
return buffer.get() & 0xFF;
|
return buffer.get() & 0xFF;
|
||||||
}
|
}
|
||||||
@ -350,12 +350,7 @@ final class Http3ServerStreamImpl {
|
|||||||
ByteBuffer buffer = current();
|
ByteBuffer buffer = current();
|
||||||
if (buffer == QuicStreamReader.EOF) {
|
if (buffer == QuicStreamReader.EOF) {
|
||||||
if (len == remaining) {
|
if (len == remaining) {
|
||||||
if (closed) {
|
return -1;
|
||||||
throw new IOException("Stream is closed");
|
|
||||||
}
|
|
||||||
var error = this.error;
|
|
||||||
if (error == null) return -1;
|
|
||||||
throw error;
|
|
||||||
} else return len - remaining;
|
} else return len - remaining;
|
||||||
}
|
}
|
||||||
int count = Math.min(buffer.remaining(), remaining);
|
int count = Math.min(buffer.remaining(), remaining);
|
||||||
@ -374,7 +369,7 @@ final class Http3ServerStreamImpl {
|
|||||||
requestBodyQueue.add(QuicStreamReader.EOF);
|
requestBodyQueue.add(QuicStreamReader.EOF);
|
||||||
}
|
}
|
||||||
|
|
||||||
void close(IOException io) {
|
void resetStream(IOException io) {
|
||||||
if (error != null) return;
|
if (error != null) return;
|
||||||
error = io;
|
error = io;
|
||||||
if (debug.on()) {
|
if (debug.on()) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user