Skip to content
Permalink
Browse files
8275079: Remove unnecessary conversion to String in java.net.http
Reviewed-by: dfuchs
  • Loading branch information
turbanoff authored and dfuch committed Oct 26, 2021
1 parent e5cd269 commit 19f76c215dbe9528dde10acd744be54618ea5e4c
Showing 13 changed files with 31 additions and 34 deletions.
@@ -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
@@ -323,7 +323,7 @@ public HttpRequestImpl response(Response r) throws IOException {
return req;
} else if (au.retries > retry_limit) {
throw new IOException("too many authentication attempts. Limit: " +
Integer.toString(retry_limit));
retry_limit);
} else {
// we sent credentials, but they were rejected
if (au.fromcache) {
@@ -116,7 +116,7 @@ static interface Http1AsyncDelegate {
public AbstractSubscription subscription();

/**
* Called to make sure resources are released when the
* Called to make sure resources are released
* when the Http1AsyncReceiver is stopped.
* @param error The Http1AsyncReceiver pending error ref,
* if any.
@@ -478,7 +478,7 @@ void onReadError(Throwable ex) {
// the pool.
if (retry && (ex instanceof IOException)) {
// could be either EOFException, or
// IOException("connection reset by peer), or
// IOException("connection reset by peer"), or
// SSLHandshakeException resulting from the server having
// closed the SSL session.
if (received.get() == 0) {
@@ -709,7 +709,7 @@ private String debugQBB(ByteBuffer[] qbb) {
for (ByteBuffer b : lbb) {
if (!sbb.remove(b)) {
msg.append(sep)
.append(String.valueOf(b))
.append(b)
.append("[remaining=")
.append(b.remaining())
.append(", position=")
@@ -727,14 +727,12 @@ private String debugQBB(ByteBuffer[] qbb) {
String dbgString() {
String tag = dbgTag;
if (tag == null) {
String flowTag = null;
Http1Exchange<?> exchg = owner;
Object flow = (exchg != null)
? exchg.connection().getConnectionFlow()
: null;
flowTag = tag = flow == null ? null: (String.valueOf(flow));
if (flowTag != null) {
dbgTag = tag = "Http1AsyncReceiver("+ flowTag + ")";
if (flow != null) {
dbgTag = tag = "Http1AsyncReceiver(" + flow + ")";
} else {
tag = "Http1AsyncReceiver(?)";
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, 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
@@ -236,7 +236,7 @@ private String hostString() {
if (defaultPort) {
return host;
} else {
return host + ":" + Integer.toString(port);
return host + ":" + port;
}
}

@@ -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
@@ -114,7 +114,7 @@ private String dbgString() {
}

// The ClientRefCountTracker is used to track the state
// of a pending operation. Altough there usually is a single
// of a pending operation. Although there usually is a single
// point where the operation starts, it may terminate at
// different places.
private final class ClientRefCountTracker {
@@ -828,7 +828,7 @@ public final void close(Throwable error) {

@Override
public String toString() {
return super.toString() + "/parser=" + String.valueOf(parser);
return super.toString() + "/parser=" + parser;
}
}
}
@@ -1008,7 +1008,7 @@ private void handleGoAway(GoAwayFrame frame)
throws IOException
{
shutdown(new IOException(
String.valueOf(connection.channel().getLocalAddress())
connection.channel().getLocalAddress()
+": GOAWAY received"));
}

@@ -44,7 +44,6 @@

import jdk.internal.net.http.common.HttpHeadersBuilder;
import jdk.internal.net.http.common.Utils;
import jdk.internal.net.http.websocket.OpeningHandshake;
import jdk.internal.net.http.websocket.WebSocketRequest;

import static jdk.internal.net.http.common.Utils.ALLOWED_HEADERS;
@@ -216,7 +215,7 @@ private BodyPublisher publisher(HttpRequestImpl other) {
this.systemHeadersBuilder.map().putAll(headers.systemHeaders().map());
this.userHeaders = headers.userHeaders();
this.uri = URI.create("socket://" + authority.getHostString() + ":"
+ Integer.toString(authority.getPort()) + "/");
+ authority.getPort() + "/");
this.proxy = null;
this.requestPublisher = null;
this.authority = authority;
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 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,7 +47,7 @@ public final class Demand {
*/
public boolean increase(long n) {
if (n <= 0) {
throw new IllegalArgumentException("non-positive subscription request: " + String.valueOf(n));
throw new IllegalArgumentException("non-positive subscription request: " + n);
}
long prev = val.getAndAccumulate(n, (p, i) -> p + i < 0 ? Long.MAX_VALUE : p + i);
return prev == 0;
@@ -938,7 +938,7 @@ private void sendResultBytes(EngineResult result) {
@Override
public String toString() {
return "WRITER: " + super.toString()
+ ", writeList size: " + Integer.toString(writeList.size())
+ ", writeList size: " + writeList.size()
+ ", scheduler: " + (scheduler.isStopped() ? "stopped" : "running")
+ ", status: " + lastWrappedStatus;
//" writeList: " + writeList.toString();
@@ -1113,7 +1113,7 @@ private void executeTasks(List<Runnable> tasks) {
exec.execute(() -> {
try {
List<Runnable> nextTasks = tasks;
if (debug.on()) debug.log("#tasks to execute: " + Integer.toString(nextTasks.size()));
if (debug.on()) debug.log("#tasks to execute: " + nextTasks.size());
do {
nextTasks.forEach(Runnable::run);
if (engine.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
@@ -490,13 +490,13 @@ public void resetDownstreamDemand() {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("SubscriberWrapper:")
.append(" upstreamCompleted: ").append(Boolean.toString(upstreamCompleted))
.append(" upstreamWindow: ").append(upstreamWindow.toString())
.append(" downstreamCompleted: ").append(Boolean.toString(downstreamCompleted))
.append(" completionAcknowledged: ").append(Boolean.toString(completionAcknowledged))
.append(" outputQ size: ").append(Integer.toString(outputQ.size()))
.append(" upstreamCompleted: ").append(upstreamCompleted)
.append(" upstreamWindow: ").append(upstreamWindow)
.append(" downstreamCompleted: ").append(downstreamCompleted)
.append(" completionAcknowledged: ").append(completionAcknowledged)
.append(" outputQ size: ").append(outputQ.size())
//.append(" outputQ: ").append(outputQ.toString())
.append(" cf: ").append(cf.toString())
.append(" cf: ").append(cf)
.append(" downstreamSubscription: ").append(downstreamSubscription)
.append(" downstreamSubscriber: ").append(downstreamSubscriber);

@@ -873,7 +873,7 @@ public static String hostString(HttpRequestImpl request) {
if (defaultPort) {
return host;
} else {
return host + ":" + Integer.toString(port);
return host + ":" + port;
}
}

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, 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
@@ -67,7 +67,7 @@ public static String stringForCode(int code) {
}

if (code > LAST_ERROR) {
return "Error: " + Integer.toString(code);
return "Error: " + code;
} else {
return errorStrings[code];
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, 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
@@ -101,7 +101,7 @@ public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(typeAsString())
.append(": length=")
.append(Integer.toString(length()))
.append(length())
.append(", streamid=")
.append(streamid)
.append(", flags=");
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, 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
@@ -55,7 +55,7 @@ public String toString() {
if (parameters[i] != -1) {
sb.append(name(i))
.append("=")
.append(Integer.toString(parameters[i]))
.append(parameters[i])
.append(' ');
}
}

1 comment on commit 19f76c2

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 19f76c2 Oct 26, 2021

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.