8309527: Improve test proxy performance

Reviewed-by: dfuchs, jpai
This commit is contained in:
Daniel Jeliński 2023-06-07 07:51:05 +00:00
parent 0ed4af76c0
commit fadcd65018
5 changed files with 29 additions and 24 deletions
test/jdk
java/net
HttpURLConnection/SetAuthenticator
httpclient
sun/net/www/http/HttpClient

@ -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
@ -1023,13 +1023,14 @@ public class HTTPTestServer extends HTTPTest {
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 {

@ -1443,18 +1443,19 @@ public abstract class DigestEchoServer implements HttpServerAdapters {
@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 {

@ -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
@ -256,13 +256,14 @@ public class ProxyTest {
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 {

@ -187,13 +187,14 @@ public class ProxyTest2 {
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 {

@ -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
@ -214,13 +214,14 @@ public class B8209178 {
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 {