Skip to content

Commit

Permalink
8309527: Improve test proxy performance
Browse files Browse the repository at this point in the history
Backport-of: fadcd6501879af40360b217d2f76ab86a6f55d27
  • Loading branch information
GoeLin committed Apr 11, 2024
1 parent 99aa1ca commit f6c003a
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 24 deletions.
@@ -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 @@ -1004,13 +1004,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
Expand Up @@ -1442,18 +1442,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
@@ -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
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
@@ -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

1 comment on commit f6c003a

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.