Skip to content

Commit

Permalink
Fix missing 'cause' arg for newReplyException()
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddenalpha committed Jul 5, 2024
1 parent 934fc11 commit 603fcd9
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public QueueStatsService(
public <CTX> void getQueueStats(CTX mCtx, GetQueueStatsMentor<CTX> mentor) {
if (!incomingRequestQuota.tryAcquire()) {
Throwable ex = exceptionFactory.newReplyException(RECIPIENT_FAILURE, 429,
"Server too busy to handle yet-another-queue-stats-request now");
"Server too busy to handle yet-another-queue-stats-request now", null);
vertx.runOnContext(v -> mentor.onError(ex, mCtx));
return;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public interface RedisQuesExceptionFactory {

public RuntimeException newRuntimeException(String message, Throwable cause);

public ReplyException newReplyException(ReplyFailure failureType, int failureCode, String msg);
public ReplyException newReplyException(ReplyFailure failureType, int failureCode, String msg, Throwable cause);


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,15 @@ public RuntimeException newRuntimeException(String message, Throwable cause) {
}

@Override
public ReplyException newReplyException(ReplyFailure failureType, int failureCode, String msg) {
return new NoStackReplyException(failureType, failureCode, msg);
public ReplyException newReplyException(ReplyFailure failureType, int failureCode, String msg, Throwable cause) {
// There was once a fix in vertx for this (https://github.com/eclipse-vertx/vert.x/issues/4840)
// but for whatever reason in our case we still see stack-trace recordings. Passing
// this subclass to {@link io.vertx.core.eventbus.Message#reply(Object)} seems to
// do the trick.
if (msg == null && cause != null) msg = cause.getMessage();
return new ReplyException(failureType, failureCode, msg) {
@Override public Throwable fillInStackTrace() { return this; }
};
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ public RuntimeException newRuntimeException(String message, Throwable cause) {
}

@Override
public ReplyException newReplyException(ReplyFailure failureType, int failureCode, String msg) {
return new ReplyException(failureType, failureCode, msg);
public ReplyException newReplyException(ReplyFailure failureType, int failureCode, String msg, Throwable cause) {
ReplyException ex = new ReplyException(failureType, failureCode, msg);
if (cause != null) ex.initCause(cause);
return ex;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void handle(AsyncResult<Response> handleQueues) {
}
if (redisRequestQuota.availablePermits() <= 0) {
event.reply(exceptionFactory.newReplyException(ReplyFailure.RECIPIENT_FAILURE, 429,
"Too many simultaneous '" + GetQueuesItemsCountHandler.class.getSimpleName() + "' requests in progress"));
"Too many simultaneous '" + GetQueuesItemsCountHandler.class.getSimpleName() + "' requests in progress", null));
return;
}

Expand Down

0 comments on commit 603fcd9

Please sign in to comment.