Skip to content
Permalink
Browse files
8255227: java/net/httpclient/FlowAdapterPublisherTest.java intermitte…
…ntly failing with TestServer: start exception: java.io.IOException: Invalid preface

Reviewed-by: chegar
  • Loading branch information
dfuch committed Apr 30, 2021
1 parent 48bb996 commit 0544a732a44309bf7cbb44846dd9320c6096de17
@@ -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 @@ else if (item == COMPLETED) {
// 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 @@ else if (item == COMPLETED) {
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.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 @@ void close(int error) {
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));
}
}

5 comments on commit 0544a73

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot replied Apr 30, 2021

@GoeLin

This comment has been minimized.

Copy link
Member

@GoeLin GoeLin replied Sep 27, 2021

/downport jdk11u-dev

@openjdk

This comment has been minimized.

Copy link

@openjdk openjdk bot replied Sep 27, 2021

Unknown command downport - for a list of valid commands use /help.

@GoeLin

This comment has been minimized.

Copy link
Member

@GoeLin GoeLin replied Sep 27, 2021

/backport jdk11u-dev

@openjdk

This comment has been minimized.

Copy link

@openjdk openjdk bot replied Sep 27, 2021

@GoeLin the backport was successfully created on the branch GoeLin-backport-0544a732 in my personal fork of openjdk/jdk11u-dev. To create a pull request with this backport targeting openjdk/jdk11u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

this pull request contains a backport of commit 0544a732 from the openjdk/jdk repository.

The commit being backported was authored by Daniel Fuchs on 30 Apr 2021 and was reviewed by Chris Hegarty.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk11u-dev:

$ git fetch https://github.com/openjdk-bots/jdk11u-dev GoeLin-backport-0544a732:GoeLin-backport-0544a732
$ git checkout GoeLin-backport-0544a732
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk11u-dev GoeLin-backport-0544a732
Please sign in to comment.