8255227: java/net/httpclient/FlowAdapterPublisherTest.java intermittently failing with TestServer: start exception: java.io.IOException: Invalid preface
Reviewed-by: chegar
This commit is contained in:
parent
48bb996ac9
commit
0544a732a4
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2021, 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
|
||||
@ -926,7 +926,6 @@ class Stream<T> extends ExchangeImpl<T> {
|
||||
// handle bytes to send downstream
|
||||
while (item.hasRemaining() && state == 0) {
|
||||
if (debug.on()) debug.log("trySend: %d", item.remaining());
|
||||
assert !endStreamSent : "internal error, send data after END_STREAM flag";
|
||||
DataFrame df = getDataFrame(item);
|
||||
if (df == null) {
|
||||
if (debug.on())
|
||||
@ -947,9 +946,12 @@ class Stream<T> extends ExchangeImpl<T> {
|
||||
connection.resetStream(streamid, ResetFrame.PROTOCOL_ERROR);
|
||||
throw new IOException(msg);
|
||||
} else if (remainingContentLength == 0) {
|
||||
assert !endStreamSent : "internal error, send data after END_STREAM flag";
|
||||
df.setFlag(DataFrame.END_STREAM);
|
||||
endStreamSent = true;
|
||||
}
|
||||
} else {
|
||||
assert !endStreamSent : "internal error, send data after END_STREAM flag";
|
||||
}
|
||||
if ((state = streamState) != 0) {
|
||||
if (debug.on()) debug.log("trySend: cancelled: %s", String.valueOf(t));
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2021, 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
|
||||
@ -47,6 +47,7 @@ import jdk.internal.net.http.hpack.DecodingCallback;
|
||||
import jdk.internal.net.http.hpack.Encoder;
|
||||
import sun.net.www.http.ChunkedInputStream;
|
||||
import sun.net.www.http.HttpClient;
|
||||
import static java.nio.charset.StandardCharsets.ISO_8859_1;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static jdk.internal.net.http.frame.SettingsFrame.HEADER_TABLE_SIZE;
|
||||
|
||||
@ -304,9 +305,11 @@ public class Http2TestServerConnection {
|
||||
private void readPreface() throws IOException {
|
||||
int len = clientPreface.length;
|
||||
byte[] bytes = new byte[len];
|
||||
is.readNBytes(bytes, 0, len);
|
||||
int n = is.readNBytes(bytes, 0, len);
|
||||
if (Arrays.compare(clientPreface, bytes) != 0) {
|
||||
throw new IOException("Invalid preface: " + new String(bytes, 0, len));
|
||||
System.err.printf("Invalid preface: read %d/%d bytes%n", n, len);
|
||||
throw new IOException("Invalid preface: " +
|
||||
new String(bytes, 0, len, ISO_8859_1));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user