Skip to content

Commit

Permalink
8309527: Improve test proxy performance
Browse files Browse the repository at this point in the history
Reviewed-by: dfuchs, jpai
  • Loading branch information
djelinski committed Jun 7, 2023
1 parent 0ed4af7 commit fadcd65
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2023, 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 Down Expand Up @@ -1023,13 +1023,14 @@ private synchronized Thread pipe(InputStream is, OutputStream os, char tag) {
public void run() {
try {
try {
int c;
while ((c = is.read()) != -1) {
os.write(c);
int len;
byte[] buf = new byte[16 * 1024];
while ((len = is.read(buf)) != -1) {
os.write(buf, 0, len);
os.flush();
// if DEBUG prints a + or a - for each transferred
// character.
if (DEBUG) System.out.print(tag);
if (DEBUG) System.out.print(String.valueOf(tag).repeat(len));
}
is.close();
} finally {
Expand Down
11 changes: 6 additions & 5 deletions test/jdk/java/net/httpclient/DigestEchoServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1443,18 +1443,19 @@ private synchronized Thread pipe(InputStream is, OutputStream os, char tag, Comp
@Override
public void run() {
try {
int c = 0;
int len = 0;
byte[] buf = new byte[16 * 1024];
try {
while ((c = is.read()) != -1) {
os.write(c);
while ((len = is.read(buf)) != -1) {
os.write(buf, 0, len);
os.flush();
// if DEBUG prints a + or a - for each transferred
// character.
if (DEBUG) System.out.print(tag);
if (DEBUG) System.out.print(String.valueOf(tag).repeat(len));
}
is.close();
} catch (IOException ex) {
if (DEBUG || !stopped && c > -1)
if (DEBUG || !stopped && len > -1)
ex.printStackTrace(System.out);
end.completeExceptionally(ex);
} finally {
Expand Down
11 changes: 6 additions & 5 deletions test/jdk/java/net/httpclient/ProxyTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, 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 Down Expand Up @@ -256,13 +256,14 @@ private synchronized Thread pipe(InputStream is, OutputStream os,
public void run() {
try {
try {
int c;
while ((c = is.read()) != -1) {
os.write(c);
int len;
byte[] buf = new byte[16 * 1024];
while ((len = is.read(buf)) != -1) {
os.write(buf, 0, len);
os.flush();
// if DEBUG prints a + or a - for each transferred
// character.
if (DEBUG) System.out.print(tag);
if (DEBUG) System.out.print(String.valueOf(tag).repeat(len));
}
is.close();
} finally {
Expand Down
9 changes: 5 additions & 4 deletions test/jdk/java/net/httpclient/http2/ProxyTest2.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,14 @@ private synchronized Thread pipe(InputStream is, OutputStream os,
public void run() {
try {
try {
int c;
while ((c = is.read()) != -1) {
os.write(c);
int len;
byte[] buf = new byte[16 * 1024];
while ((len = is.read(buf)) != -1) {
os.write(buf, 0, len);
os.flush();
// if DEBUG prints a + or a - for each transferred
// character.
if (DEBUG) System.out.print(tag);
if (DEBUG) System.out.print(String.valueOf(tag).repeat(len));
}
is.close();
} finally {
Expand Down
11 changes: 6 additions & 5 deletions test/jdk/sun/net/www/http/HttpClient/B8209178.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2023, 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 Down Expand Up @@ -214,13 +214,14 @@ private synchronized Thread pipe(InputStream is, OutputStream os, char tag) {
public void run() {
try {
try {
int c;
while ((c = is.read()) != -1) {
os.write(c);
int len;
byte[] buf = new byte[16 * 1024];
while ((len = is.read(buf)) != -1) {
os.write(buf, 0, len);
os.flush();
// if DEBUG prints a + or a - for each transferred
// character.
if (DEBUG) System.out.print(tag);
if (DEBUG) System.out.print(String.valueOf(tag).repeat(len));
}
is.close();
} finally {
Expand Down

5 comments on commit fadcd65

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on fadcd65 Apr 10, 2024

Choose a reason for hiding this comment

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

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on fadcd65 Apr 10, 2024

Choose a reason for hiding this comment

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

@GoeLin Could not apply backport fadcd650 to openjdk/jdk21u-dev because the change is already present in the target.

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on fadcd65 Apr 10, 2024

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on fadcd65 Apr 10, 2024

Choose a reason for hiding this comment

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

@GoeLin the backport was successfully created on the branch backport-GoeLin-fadcd650 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-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 fadcd650 from the openjdk/jdk repository.

The commit being backported was authored by Daniel Jeliński on 7 Jun 2023 and was reviewed by Daniel Fuchs and Jaikiran Pai.

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/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev.git backport-GoeLin-fadcd650:backport-GoeLin-fadcd650
$ git checkout backport-GoeLin-fadcd650
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev.git backport-GoeLin-fadcd650

Please sign in to comment.