Skip to content

Commit

Permalink
update failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhee17 committed Dec 21, 2023
1 parent 2cdc080 commit 57e1144
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,6 @@ private DefaultClientRequestContext(DefaultClientRequestContext ctx,
log.startRequest();
responseCancellationScheduler =
CancellationScheduler.of(TimeUnit.MILLISECONDS.toNanos(ctx.responseTimeoutMillis()));
updateEventLoop(ctx.eventLoop().withoutContext());
writeTimeoutMillis = ctx.writeTimeoutMillis();
maxResponseLength = ctx.maxResponseLength();

Expand All @@ -541,7 +540,7 @@ private DefaultClientRequestContext(DefaultClientRequestContext ctx,
// We don't need to acquire an EventLoop for the initial attempt because it's already acquired by
// the root context.
if (endpoint == null || ctx.endpoint() == endpoint && ctx.log.children().isEmpty()) {
eventLoop = ctx.eventLoop().withoutContext();
updateEventLoop(ctx.eventLoop().withoutContext());
} else {
acquireEventLoop(endpoint);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import com.linecorp.armeria.common.annotation.Nullable;
import com.linecorp.armeria.common.util.TimeoutMode;
import com.linecorp.armeria.common.util.UnmodifiableFuture;
import com.linecorp.armeria.server.HttpResponseException;
import com.linecorp.armeria.server.HttpStatusException;
import com.linecorp.armeria.server.RequestTimeoutException;

import io.netty.util.concurrent.EventExecutor;
Expand Down Expand Up @@ -355,7 +357,7 @@ public void finishNow(@Nullable Throwable cause) {
}
if (state == State.INIT) {
state = State.FINISHED;
this.cause = getThrowable(server, cause);
this.cause = mapThrowable(server, cause);
((CancellationFuture) whenCancelled()).doComplete(cause);
} else if (isInitialized()) {
if (eventLoop.inEventLoop()) {
Expand Down Expand Up @@ -527,7 +529,7 @@ private void invokeTask(@Nullable Throwable cause) {
return;
}

cause = getThrowable(server, cause);
cause = mapThrowable(server, cause);

// Set FINISHING to preclude executing other timeout operations from the callbacks of `whenCancelling()`
state = State.FINISHING;
Expand All @@ -545,14 +547,18 @@ private void invokeTask(@Nullable Throwable cause) {
((CancellationFuture) whenCancelled()).doComplete(cause);
}

private static Throwable getThrowable(boolean server, @Nullable Throwable cause) {
if (cause != null) {
return cause;
private static Throwable mapThrowable(boolean server, @Nullable Throwable cause) {
if (cause instanceof HttpStatusException || cause instanceof HttpResponseException) {
// Log the requestCause only when an Http{Status,Response}Exception was created with a cause.
cause = cause.getCause();
}
if (server) {
cause = RequestTimeoutException.get();
} else {
cause = ResponseTimeoutException.get();

if (cause == null) {
if (server) {
cause = RequestTimeoutException.get();
} else {
cause = ResponseTimeoutException.get();
}
}
return cause;
}
Expand Down

0 comments on commit 57e1144

Please sign in to comment.