Skip to content

Reduce GC overhead by call address.toString() in case of timeout only #1401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class TimeoutsHolder {
private volatile NettyResponseFuture<?> nettyResponseFuture;
public final Timeout requestTimeout;
public volatile Timeout readTimeout;
private volatile String remoteAddress = "not-connected";
private volatile InetSocketAddress remoteAddress;

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

public void initRemoteAddress(InetSocketAddress address) {
remoteAddress = address.toString();
remoteAddress = address;
}

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

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

String remoteAddress() {
return remoteAddress;
return remoteAddress == null ? "not-connected" : remoteAddress.toString();
}
}