Skip to content

Commit d86d481

Browse files
plokhotnyukslandelle
authored andcommitted
Reduce GC overhead by call address.toString() in case of timeout only (AsyncHttpClient#1401)
1 parent e00c35b commit d86d481

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

client/src/main/java/org/asynchttpclient/netty/timeout/TimeoutsHolder.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class TimeoutsHolder {
3939
private volatile NettyResponseFuture<?> nettyResponseFuture;
4040
public final Timeout requestTimeout;
4141
public volatile Timeout readTimeout;
42-
private volatile String remoteAddress = "not-connected";
42+
private volatile InetSocketAddress remoteAddress;
4343

4444
public TimeoutsHolder(Timer nettyTimer, NettyResponseFuture<?> nettyResponseFuture, NettyRequestSender requestSender, AsyncHttpClientConfig config) {
4545
this.nettyTimer = nettyTimer;
@@ -66,7 +66,7 @@ public TimeoutsHolder(Timer nettyTimer, NettyResponseFuture<?> nettyResponseFutu
6666
}
6767

6868
public void initRemoteAddress(InetSocketAddress address) {
69-
remoteAddress = address.toString();
69+
remoteAddress = address;
7070
}
7171

7272
public void startReadTimeout() {
@@ -82,8 +82,7 @@ void startReadTimeout(ReadTimeoutTimerTask task) {
8282
// first call triggered from outside (else is read timeout is re-scheduling itself)
8383
task = new ReadTimeoutTimerTask(nettyResponseFuture, requestSender, this, readTimeoutValue);
8484
}
85-
Timeout readTimeout = newTimeout(task, readTimeoutValue);
86-
this.readTimeout = readTimeout;
85+
this.readTimeout = newTimeout(task, readTimeoutValue);
8786

8887
} else if (task != null) {
8988
// read timeout couldn't re-scheduling itself, clean up
@@ -109,6 +108,6 @@ private Timeout newTimeout(TimerTask task, long delay) {
109108
}
110109

111110
String remoteAddress() {
112-
return remoteAddress;
111+
return remoteAddress == null ? "not-connected" : remoteAddress.toString();
113112
}
114113
}

0 commit comments

Comments
 (0)