Skip to content

Fix. retry is incremented by twice #1150

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
Show file tree
Hide file tree
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 @@ -425,7 +425,7 @@ public boolean reuseChannel() {
return reuseChannel;
}

public boolean canRetry() {
public boolean incRetryAndCheck() {
return maxRetry > 0 && CURRENT_RETRY_UPDATER.incrementAndGet(this) <= maxRetry;
}

Expand All @@ -444,7 +444,7 @@ public void setCurrentRequest(Request currentRequest) {
* @return true if that {@link Future} cannot be recovered.
*/
public boolean canBeReplayed() {
return !isDone() && canRetry() && !(Channels.isChannelValid(channel) && !getUri().getScheme().equalsIgnoreCase("https")) && !inAuth.get() && !inProxyAuth.get();
return !isDone() && !(Channels.isChannelValid(channel) && !getUri().getScheme().equalsIgnoreCase("https")) && !inAuth.get() && !inProxyAuth.get();
}

public long getStart() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void onFailure(Channel channel, Throwable cause) {
//beware, channel can be null
abortChannelPreemption();

boolean canRetry = future.canRetry();
boolean canRetry = future.incRetryAndCheck();
LOGGER.debug("Trying to recover from failing to connect channel {} with a retry value of {} ", channel, canRetry);
if (canRetry//
&& cause != null // FIXME when can we have a null cause?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public void abort(Channel channel, NettyResponseFuture<?> future, Throwable t) {
public void handleUnexpectedClosedChannel(Channel channel, NettyResponseFuture<?> future) {
if (future.isDone()) {
channelManager.closeChannel(channel);
} else if (retry(future)) {
} else if (future.incRetryAndCheck() && retry(future)) {
future.pendingException = null;
} else {
abort(channel, future, future.pendingException != null ? future.pendingException : RemotelyClosedException.INSTANCE);
Expand Down Expand Up @@ -447,7 +447,7 @@ public boolean applyIoExceptionFiltersAndReplayRequest(NettyResponseFuture<?> fu
}
}

if (fc.replayRequest() && future.canBeReplayed()) {
if (fc.replayRequest() && future.canBeReplayed() && future.incRetryAndCheck()) {
replayRequest(future, fc, channel);
replayed = true;
}
Expand Down