diff --git a/src/main/java/org/swisspush/redisques/QueueStatsService.java b/src/main/java/org/swisspush/redisques/QueueStatsService.java index d9a3bdc..71e1534 100644 --- a/src/main/java/org/swisspush/redisques/QueueStatsService.java +++ b/src/main/java/org/swisspush/redisques/QueueStatsService.java @@ -19,7 +19,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.BiConsumer; -import static io.vertx.core.eventbus.ReplyFailure.RECIPIENT_FAILURE; import static java.lang.Long.compare; import static java.lang.System.currentTimeMillis; import static java.util.Collections.emptyList; @@ -72,7 +71,7 @@ public QueueStatsService( public void getQueueStats(CTX mCtx, GetQueueStatsMentor mentor) { if (!incomingRequestQuota.tryAcquire()) { - Throwable ex = exceptionFactory.newReplyException(RECIPIENT_FAILURE, 429, + Throwable ex = exceptionFactory.newReplyException(429, "Server too busy to handle yet-another-queue-stats-request now", null); vertx.runOnContext(v -> mentor.onError(ex, mCtx)); return; diff --git a/src/main/java/org/swisspush/redisques/action/AbstractQueueAction.java b/src/main/java/org/swisspush/redisques/action/AbstractQueueAction.java index bb634fd..3de2a82 100644 --- a/src/main/java/org/swisspush/redisques/action/AbstractQueueAction.java +++ b/src/main/java/org/swisspush/redisques/action/AbstractQueueAction.java @@ -19,7 +19,6 @@ import java.util.List; import java.util.Objects; -import static io.vertx.core.eventbus.ReplyFailure.RECIPIENT_FAILURE; import static org.swisspush.redisques.util.RedisquesAPI.*; public abstract class AbstractQueueAction implements QueueAction { @@ -61,8 +60,8 @@ protected Handler replyErrorMessageHandler(Message event) }; } - protected void handleFail(Message event, String message, Throwable cause) { - event.reply(exceptionFactory.newReplyException(RECIPIENT_FAILURE, 0, null, cause)); + protected void handleFail(Message event, String msg, Throwable cause) { + event.reply(exceptionFactory.newReplyException(msg, cause)); } protected long getMaxAgeTimestamp() { diff --git a/src/main/java/org/swisspush/redisques/action/GetQueueItemsAction.java b/src/main/java/org/swisspush/redisques/action/GetQueueItemsAction.java index e52d02a..4069ff1 100644 --- a/src/main/java/org/swisspush/redisques/action/GetQueueItemsAction.java +++ b/src/main/java/org/swisspush/redisques/action/GetQueueItemsAction.java @@ -12,7 +12,6 @@ import java.util.List; -import static io.vertx.core.eventbus.ReplyFailure.RECIPIENT_FAILURE; import static org.swisspush.redisques.util.RedisquesAPI.*; public class GetQueueItemsAction extends AbstractQueueAction { @@ -38,8 +37,8 @@ public void execute(Message event) { redisAPI.lrange(keyListRange, "0", String.valueOf(maxQueueItemCountIndex), new GetQueueItemsHandler(event, queueItemCount)); } else { - event.reply(exceptionFactory.newReplyException(RECIPIENT_FAILURE, 0, - "Operation getQueueItems failed to extract queueItemCount", null)); + event.reply(exceptionFactory.newReplyException( + "Operation getQueueItems failed to extract queueItemCount", null)); } }).onFailure(throwable -> handleFail(event, "Operation getQueueItems failed", throwable))) .onFailure(throwable -> handleFail(event, "Operation getQueueItems failed", throwable)); diff --git a/src/main/java/org/swisspush/redisques/exception/RedisQuesExceptionFactory.java b/src/main/java/org/swisspush/redisques/exception/RedisQuesExceptionFactory.java index 493b5e4..1787ed6 100644 --- a/src/main/java/org/swisspush/redisques/exception/RedisQuesExceptionFactory.java +++ b/src/main/java/org/swisspush/redisques/exception/RedisQuesExceptionFactory.java @@ -1,7 +1,6 @@ package org.swisspush.redisques.exception; import io.vertx.core.eventbus.ReplyException; -import io.vertx.core.eventbus.ReplyFailure; /** @@ -30,7 +29,11 @@ public interface RedisQuesExceptionFactory { public RuntimeException newRuntimeException(String message, Throwable cause); - public ReplyException newReplyException(ReplyFailure failureType, int failureCode, String msg, Throwable cause); + default ReplyException newReplyException(String msg, Throwable cause) { + return newReplyException(0, msg, cause); + } + + public ReplyException newReplyException(int failureCode, String msg, Throwable cause); /** diff --git a/src/main/java/org/swisspush/redisques/exception/ThriftyRedisQuesExceptionFactory.java b/src/main/java/org/swisspush/redisques/exception/ThriftyRedisQuesExceptionFactory.java index 805cc29..c4ab21a 100644 --- a/src/main/java/org/swisspush/redisques/exception/ThriftyRedisQuesExceptionFactory.java +++ b/src/main/java/org/swisspush/redisques/exception/ThriftyRedisQuesExceptionFactory.java @@ -33,13 +33,13 @@ public RuntimeException newRuntimeException(String message, Throwable cause) { } @Override - public ReplyException newReplyException(ReplyFailure failureType, int failureCode, String msg, Throwable cause) { + public ReplyException newReplyException(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) { + return new ReplyException(ReplyFailure.RECIPIENT_FAILURE, failureCode, msg) { @Override public Throwable fillInStackTrace() { return this; } }; } diff --git a/src/main/java/org/swisspush/redisques/exception/WastefulRedisQuesExceptionFactory.java b/src/main/java/org/swisspush/redisques/exception/WastefulRedisQuesExceptionFactory.java index a3190d5..7bf32e4 100644 --- a/src/main/java/org/swisspush/redisques/exception/WastefulRedisQuesExceptionFactory.java +++ b/src/main/java/org/swisspush/redisques/exception/WastefulRedisQuesExceptionFactory.java @@ -26,9 +26,9 @@ public RuntimeException newRuntimeException(String message, Throwable cause) { } @Override - public ReplyException newReplyException(ReplyFailure failureType, int failureCode, String msg, Throwable cause) { + public ReplyException newReplyException(int failureCode, String msg, Throwable cause) { if (msg == null && cause != null) msg = cause.getMessage(); - ReplyException ex = new ReplyException(failureType, failureCode, msg); + ReplyException ex = new ReplyException(ReplyFailure.RECIPIENT_FAILURE, failureCode, msg); if (cause != null) ex.initCause(cause); return ex; } diff --git a/src/main/java/org/swisspush/redisques/handler/AddQueueItemHandler.java b/src/main/java/org/swisspush/redisques/handler/AddQueueItemHandler.java index 32baa50..015b26c 100644 --- a/src/main/java/org/swisspush/redisques/handler/AddQueueItemHandler.java +++ b/src/main/java/org/swisspush/redisques/handler/AddQueueItemHandler.java @@ -8,7 +8,6 @@ import org.slf4j.Logger; import org.swisspush.redisques.exception.RedisQuesExceptionFactory; -import static io.vertx.core.eventbus.ReplyFailure.RECIPIENT_FAILURE; import static org.slf4j.LoggerFactory.getLogger; import static org.swisspush.redisques.util.RedisquesAPI.OK; import static org.swisspush.redisques.util.RedisquesAPI.STATUS; @@ -34,7 +33,7 @@ public void handle(AsyncResult reply) { if(reply.succeeded()){ event.reply(new JsonObject().put(STATUS, OK)); } else { - event.reply(exceptionFactory.newReplyException(RECIPIENT_FAILURE, 0, null, reply.cause())); + event.reply(exceptionFactory.newReplyException(null, reply.cause())); } } } diff --git a/src/main/java/org/swisspush/redisques/handler/DeleteLockHandler.java b/src/main/java/org/swisspush/redisques/handler/DeleteLockHandler.java index 72c50d1..89db14d 100644 --- a/src/main/java/org/swisspush/redisques/handler/DeleteLockHandler.java +++ b/src/main/java/org/swisspush/redisques/handler/DeleteLockHandler.java @@ -8,7 +8,6 @@ import org.slf4j.Logger; import org.swisspush.redisques.exception.RedisQuesExceptionFactory; -import static io.vertx.core.eventbus.ReplyFailure.RECIPIENT_FAILURE; import static org.slf4j.LoggerFactory.getLogger; import static org.swisspush.redisques.util.RedisquesAPI.OK; import static org.swisspush.redisques.util.RedisquesAPI.STATUS; @@ -34,7 +33,7 @@ public void handle(AsyncResult reply) { if (reply.succeeded()) { event.reply(new JsonObject().put(STATUS, OK)); } else { - event.reply(exceptionFactory.newReplyException(RECIPIENT_FAILURE, 0, null, reply.cause())); + event.reply(exceptionFactory.newReplyException(null, reply.cause())); } } } diff --git a/src/main/java/org/swisspush/redisques/handler/GetLockHandler.java b/src/main/java/org/swisspush/redisques/handler/GetLockHandler.java index 8ed7a90..8dd4d38 100644 --- a/src/main/java/org/swisspush/redisques/handler/GetLockHandler.java +++ b/src/main/java/org/swisspush/redisques/handler/GetLockHandler.java @@ -8,7 +8,6 @@ import org.slf4j.Logger; import org.swisspush.redisques.exception.RedisQuesExceptionFactory; -import static io.vertx.core.eventbus.ReplyFailure.RECIPIENT_FAILURE; import static org.slf4j.LoggerFactory.getLogger; import static org.swisspush.redisques.util.RedisquesAPI.NO_SUCH_LOCK; import static org.swisspush.redisques.util.RedisquesAPI.OK; @@ -40,7 +39,7 @@ public void handle(AsyncResult reply) { event.reply(new JsonObject().put(STATUS, NO_SUCH_LOCK)); } } else { - event.reply(exceptionFactory.newReplyException(RECIPIENT_FAILURE, 0, null, reply.cause())); + event.reply(exceptionFactory.newReplyException(null, reply.cause())); } } diff --git a/src/main/java/org/swisspush/redisques/handler/GetQueueItemHandler.java b/src/main/java/org/swisspush/redisques/handler/GetQueueItemHandler.java index 08ab385..d99b355 100644 --- a/src/main/java/org/swisspush/redisques/handler/GetQueueItemHandler.java +++ b/src/main/java/org/swisspush/redisques/handler/GetQueueItemHandler.java @@ -33,7 +33,7 @@ public GetQueueItemHandler(Message event, RedisQuesExceptionFactory @Override public void handle(AsyncResult reply) { if(reply.failed()) { - event.reply(exceptionFactory.newReplyException(io.vertx.core.eventbus.ReplyFailure.RECIPIENT_FAILURE, 0, null, reply.cause())); + event.reply(exceptionFactory.newReplyException(null, reply.cause())); } else if (reply.result() != null) { event.reply(new JsonObject().put(STATUS, OK).put(VALUE, reply.result().toString())); } else { diff --git a/src/main/java/org/swisspush/redisques/handler/GetQueuesItemsCountHandler.java b/src/main/java/org/swisspush/redisques/handler/GetQueuesItemsCountHandler.java index 5e5a0ff..589b35a 100644 --- a/src/main/java/org/swisspush/redisques/handler/GetQueuesItemsCountHandler.java +++ b/src/main/java/org/swisspush/redisques/handler/GetQueuesItemsCountHandler.java @@ -5,7 +5,6 @@ import io.vertx.core.Promise; import io.vertx.core.Vertx; import io.vertx.core.eventbus.Message; -import io.vertx.core.eventbus.ReplyFailure; import io.vertx.core.json.JsonArray; import io.vertx.core.json.JsonObject; import io.vertx.redis.client.Command; @@ -87,7 +86,7 @@ public void handle(AsyncResult handleQueues) { return; } if (redisRequestQuota.availablePermits() <= 0) { - event.reply(exceptionFactory.newReplyException(ReplyFailure.RECIPIENT_FAILURE, 429, + event.reply(exceptionFactory.newReplyException(429, "Too many simultaneous '" + GetQueuesItemsCountHandler.class.getSimpleName() + "' requests in progress", null)); return; } diff --git a/src/main/java/org/swisspush/redisques/handler/PutLockHandler.java b/src/main/java/org/swisspush/redisques/handler/PutLockHandler.java index eef3d21..8229f90 100644 --- a/src/main/java/org/swisspush/redisques/handler/PutLockHandler.java +++ b/src/main/java/org/swisspush/redisques/handler/PutLockHandler.java @@ -8,7 +8,6 @@ import org.slf4j.Logger; import org.swisspush.redisques.exception.RedisQuesExceptionFactory; -import static io.vertx.core.eventbus.ReplyFailure.RECIPIENT_FAILURE; import static org.slf4j.LoggerFactory.getLogger; import static org.swisspush.redisques.util.RedisquesAPI.OK; import static org.swisspush.redisques.util.RedisquesAPI.STATUS; @@ -34,7 +33,7 @@ public void handle(AsyncResult reply) { if(reply.succeeded()){ event.reply(new JsonObject().put(STATUS, OK)); } else { - event.reply(exceptionFactory.newReplyException(RECIPIENT_FAILURE, 0, reply.cause().getMessage(), reply.cause())); + event.reply(exceptionFactory.newReplyException(reply.cause().getMessage(), reply.cause())); } } diff --git a/src/main/java/org/swisspush/redisques/handler/ReplaceQueueItemHandler.java b/src/main/java/org/swisspush/redisques/handler/ReplaceQueueItemHandler.java index 2c796f9..bcc43cb 100644 --- a/src/main/java/org/swisspush/redisques/handler/ReplaceQueueItemHandler.java +++ b/src/main/java/org/swisspush/redisques/handler/ReplaceQueueItemHandler.java @@ -8,7 +8,6 @@ import org.slf4j.Logger; import org.swisspush.redisques.exception.RedisQuesExceptionFactory; -import static io.vertx.core.eventbus.ReplyFailure.RECIPIENT_FAILURE; import static org.slf4j.LoggerFactory.getLogger; import static org.swisspush.redisques.util.RedisquesAPI.ERROR; import static org.swisspush.redisques.util.RedisquesAPI.OK; @@ -37,7 +36,7 @@ public void handle(AsyncResult reply) { } else if(checkRedisErrorCodes(reply.cause().getMessage())) { event.reply(new JsonObject().put(STATUS, ERROR)); } else { - event.reply(exceptionFactory.newReplyException(RECIPIENT_FAILURE, 0, reply.cause().getMessage(), reply.cause())); + event.reply(exceptionFactory.newReplyException(null, reply.cause())); } }