From 07a711df2c4c94c42662bf7428d0f99414350fd3 Mon Sep 17 00:00:00 2001 From: Andreas Fankhauser <23085769+hiddenalpha@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:42:33 +0100 Subject: [PATCH] [SDCISA-10974, SDCISA-14097] Disclose errors in Handlers --- .../handler/AddQueueItemHandler.java | 9 +- .../redisques/handler/DeleteLockHandler.java | 69 ++++++++------ .../redisques/handler/GetAllLocksHandler.java | 94 ++++++++++--------- .../redisques/handler/GetLockHandler.java | 80 +++++++++------- .../handler/GetQueueItemHandler.java | 12 ++- .../handler/GetQueueItemsCountHandler.java | 10 +- .../handler/GetQueueItemsHandler.java | 17 +++- .../handler/GetQueuesCountHandler.java | 11 ++- .../redisques/handler/GetQueuesHandler.java | 10 +- .../handler/GetQueuesItemsCountHandler.java | 21 +++-- .../handler/GetQueuesSpeedHandler.java | 23 +++-- .../handler/GetQueuesStatisticsHandler.java | 24 +++-- .../redisques/handler/PutLockHandler.java | 69 ++++++++------ .../handler/ReplaceQueueItemHandler.java | 11 ++- 14 files changed, 286 insertions(+), 174 deletions(-) diff --git a/src/main/java/org/swisspush/redisques/handler/AddQueueItemHandler.java b/src/main/java/org/swisspush/redisques/handler/AddQueueItemHandler.java index c8f20a93..74735582 100644 --- a/src/main/java/org/swisspush/redisques/handler/AddQueueItemHandler.java +++ b/src/main/java/org/swisspush/redisques/handler/AddQueueItemHandler.java @@ -5,8 +5,12 @@ import io.vertx.core.eventbus.Message; import io.vertx.core.json.JsonObject; import io.vertx.redis.client.Response; +import org.slf4j.Logger; -import static org.swisspush.redisques.util.RedisquesAPI.*; +import static org.slf4j.LoggerFactory.getLogger; +import static org.swisspush.redisques.util.RedisquesAPI.ERROR; +import static org.swisspush.redisques.util.RedisquesAPI.OK; +import static org.swisspush.redisques.util.RedisquesAPI.STATUS; /** * Class AddQueueItemHandler. @@ -14,6 +18,8 @@ * @author baldim, https://github.com/mcweba [Marc-Andre Weber] */ public class AddQueueItemHandler implements Handler> { + + private static final Logger log = getLogger(AddQueueItemHandler.class); private final Message event; public AddQueueItemHandler(Message event) { @@ -25,6 +31,7 @@ public void handle(AsyncResult reply) { if(reply.succeeded()){ event.reply(new JsonObject().put(STATUS, OK)); } else { + log.warn("Concealed error", new Exception(reply.cause())); event.reply(new JsonObject().put(STATUS, ERROR)); } } diff --git a/src/main/java/org/swisspush/redisques/handler/DeleteLockHandler.java b/src/main/java/org/swisspush/redisques/handler/DeleteLockHandler.java index 6ad985ed..7dbf9f71 100644 --- a/src/main/java/org/swisspush/redisques/handler/DeleteLockHandler.java +++ b/src/main/java/org/swisspush/redisques/handler/DeleteLockHandler.java @@ -1,31 +1,38 @@ -package org.swisspush.redisques.handler; - -import io.vertx.core.AsyncResult; -import io.vertx.core.Handler; -import io.vertx.core.eventbus.Message; -import io.vertx.core.json.JsonObject; -import io.vertx.redis.client.Response; - -import static org.swisspush.redisques.util.RedisquesAPI.*; - -/** - * Class DeleteLockHandler. - * - * @author baldim - */ -public class DeleteLockHandler implements Handler> { - private final Message event; - - public DeleteLockHandler(Message event) { - this.event = event; - } - - @Override - public void handle(AsyncResult reply) { - if (reply.succeeded()) { - event.reply(new JsonObject().put(STATUS, OK)); - } else { - event.reply(new JsonObject().put(STATUS, ERROR)); - } - } -} +package org.swisspush.redisques.handler; + +import io.vertx.core.AsyncResult; +import io.vertx.core.Handler; +import io.vertx.core.eventbus.Message; +import io.vertx.core.json.JsonObject; +import io.vertx.redis.client.Response; +import org.slf4j.Logger; + +import static org.slf4j.LoggerFactory.getLogger; +import static org.swisspush.redisques.util.RedisquesAPI.ERROR; +import static org.swisspush.redisques.util.RedisquesAPI.OK; +import static org.swisspush.redisques.util.RedisquesAPI.STATUS; + +/** + * Class DeleteLockHandler. + * + * @author baldim + */ +public class DeleteLockHandler implements Handler> { + + private static final Logger log = getLogger(DeleteLockHandler.class); + private final Message event; + + public DeleteLockHandler(Message event) { + this.event = event; + } + + @Override + public void handle(AsyncResult reply) { + if (reply.succeeded()) { + event.reply(new JsonObject().put(STATUS, OK)); + } else { + log.warn("Concealed error", new Exception(reply.cause())); + event.reply(new JsonObject().put(STATUS, ERROR)); + } + } +} diff --git a/src/main/java/org/swisspush/redisques/handler/GetAllLocksHandler.java b/src/main/java/org/swisspush/redisques/handler/GetAllLocksHandler.java index c1dbbe4f..7c49c9cb 100644 --- a/src/main/java/org/swisspush/redisques/handler/GetAllLocksHandler.java +++ b/src/main/java/org/swisspush/redisques/handler/GetAllLocksHandler.java @@ -1,44 +1,52 @@ -package org.swisspush.redisques.handler; - -import io.vertx.core.AsyncResult; -import io.vertx.core.Handler; -import io.vertx.core.eventbus.Message; -import io.vertx.core.json.JsonArray; -import io.vertx.core.json.JsonObject; -import io.vertx.redis.client.Response; -import org.swisspush.redisques.util.HandlerUtil; - -import java.util.List; -import java.util.Optional; -import java.util.regex.Pattern; - -import static org.swisspush.redisques.util.RedisquesAPI.*; - -/** - * Class GetAllLocksHandler. - * - * @author baldim - */ -public class GetAllLocksHandler implements Handler> { - - private final Message event; - private final Optional filterPattern; - - public GetAllLocksHandler(Message event, Optional filterPattern) { - this.event = event; - this.filterPattern = filterPattern; - } - - @Override - public void handle(AsyncResult reply) { - if (reply.succeeded() && reply.result() != null) { - JsonObject result = new JsonObject(); - Response locks = reply.result(); - List filteredLocks = HandlerUtil.filterByPattern(locks, filterPattern); - result.put("locks", new JsonArray(filteredLocks)); - event.reply(new JsonObject().put(STATUS, OK).put(VALUE, result)); - } else { - event.reply(new JsonObject().put(STATUS, ERROR)); - } - } +package org.swisspush.redisques.handler; + +import io.vertx.core.AsyncResult; +import io.vertx.core.Handler; +import io.vertx.core.eventbus.Message; +import io.vertx.core.json.JsonArray; +import io.vertx.core.json.JsonObject; +import io.vertx.redis.client.Response; +import org.slf4j.Logger; +import org.swisspush.redisques.util.HandlerUtil; + +import java.util.List; +import java.util.Optional; +import java.util.regex.Pattern; + +import static org.slf4j.LoggerFactory.getLogger; +import static org.swisspush.redisques.util.RedisquesAPI.ERROR; +import static org.swisspush.redisques.util.RedisquesAPI.OK; +import static org.swisspush.redisques.util.RedisquesAPI.STATUS; +import static org.swisspush.redisques.util.RedisquesAPI.VALUE; + +/** + * Class GetAllLocksHandler. + * + * @author baldim + */ +public class GetAllLocksHandler implements Handler> { + + private static final Logger log = getLogger(GetAllLocksHandler.class); + private final Message event; + private final Optional filterPattern; + + public GetAllLocksHandler(Message event, Optional filterPattern) { + this.event = event; + this.filterPattern = filterPattern; + } + + @Override + public void handle(AsyncResult reply) { + if (reply.succeeded() && reply.result() != null) { + JsonObject result = new JsonObject(); + Response locks = reply.result(); + List filteredLocks = HandlerUtil.filterByPattern(locks, filterPattern); + result.put("locks", new JsonArray(filteredLocks)); + event.reply(new JsonObject().put(STATUS, OK).put(VALUE, result)); + } else { + if( reply.failed() ) log.warn("Concealed error", new Exception(reply.cause())); + event.reply(new JsonObject().put(STATUS, ERROR)); + } + } + } \ No newline at end of file diff --git a/src/main/java/org/swisspush/redisques/handler/GetLockHandler.java b/src/main/java/org/swisspush/redisques/handler/GetLockHandler.java index 27d9bd6f..d40b6734 100644 --- a/src/main/java/org/swisspush/redisques/handler/GetLockHandler.java +++ b/src/main/java/org/swisspush/redisques/handler/GetLockHandler.java @@ -1,35 +1,45 @@ -package org.swisspush.redisques.handler; - -import io.vertx.core.AsyncResult; -import io.vertx.core.Handler; -import io.vertx.core.eventbus.Message; -import io.vertx.core.json.JsonObject; -import io.vertx.redis.client.Response; - -import static org.swisspush.redisques.util.RedisquesAPI.*; - -/** - * Class GetLockHandler. - * - * @author baldim - */ -public class GetLockHandler implements Handler> { - private final Message event; - - public GetLockHandler(Message event) { - this.event = event; - } - - @Override - public void handle(AsyncResult reply) { - if (reply.succeeded()) { - if (reply.result() != null) { - event.reply(new JsonObject().put(STATUS, OK).put(VALUE, reply.result().toString())); - } else { - event.reply(new JsonObject().put(STATUS, NO_SUCH_LOCK)); - } - } else { - event.reply(new JsonObject().put(STATUS, ERROR)); - } - } -} +package org.swisspush.redisques.handler; + +import io.vertx.core.AsyncResult; +import io.vertx.core.Handler; +import io.vertx.core.eventbus.Message; +import io.vertx.core.json.JsonObject; +import io.vertx.redis.client.Response; +import org.slf4j.Logger; + +import static org.slf4j.LoggerFactory.getLogger; +import static org.swisspush.redisques.util.RedisquesAPI.ERROR; +import static org.swisspush.redisques.util.RedisquesAPI.NO_SUCH_LOCK; +import static org.swisspush.redisques.util.RedisquesAPI.OK; +import static org.swisspush.redisques.util.RedisquesAPI.STATUS; +import static org.swisspush.redisques.util.RedisquesAPI.VALUE; + +/** + * Class GetLockHandler. + * + * @author baldim + */ +public class GetLockHandler implements Handler> { + + private static final Logger log = getLogger(GetLockHandler.class); + private final Message event; + + public GetLockHandler(Message event) { + this.event = event; + } + + @Override + public void handle(AsyncResult reply) { + if (reply.succeeded()) { + if (reply.result() != null) { + event.reply(new JsonObject().put(STATUS, OK).put(VALUE, reply.result().toString())); + } else { + event.reply(new JsonObject().put(STATUS, NO_SUCH_LOCK)); + } + } else { + log.warn("Concealed error", new Exception(reply.cause())); + event.reply(new JsonObject().put(STATUS, ERROR)); + } + } + +} diff --git a/src/main/java/org/swisspush/redisques/handler/GetQueueItemHandler.java b/src/main/java/org/swisspush/redisques/handler/GetQueueItemHandler.java index 8f82b558..57c7915f 100644 --- a/src/main/java/org/swisspush/redisques/handler/GetQueueItemHandler.java +++ b/src/main/java/org/swisspush/redisques/handler/GetQueueItemHandler.java @@ -1,11 +1,17 @@ package org.swisspush.redisques.handler; import io.vertx.core.AsyncResult; -import static org.swisspush.redisques.util.RedisquesAPI.*; import io.vertx.core.Handler; import io.vertx.core.eventbus.Message; import io.vertx.core.json.JsonObject; import io.vertx.redis.client.Response; +import org.slf4j.Logger; + +import static org.slf4j.LoggerFactory.getLogger; +import static org.swisspush.redisques.util.RedisquesAPI.ERROR; +import static org.swisspush.redisques.util.RedisquesAPI.OK; +import static org.swisspush.redisques.util.RedisquesAPI.STATUS; +import static org.swisspush.redisques.util.RedisquesAPI.VALUE; /** * Class GetQueueItemHandler. @@ -13,6 +19,8 @@ * @author baldim, https://github.com/mcweba [Marc-Andre Weber] */ public class GetQueueItemHandler implements Handler> { + + private static final Logger log = getLogger(GetQueueItemHandler.class); private final Message event; public GetQueueItemHandler(Message event) { @@ -24,7 +32,9 @@ public void handle(AsyncResult reply) { if (reply.succeeded() && reply.result() != null) { event.reply(new JsonObject().put(STATUS, OK).put(VALUE, reply.result().toString())); } else { + if( reply.failed() ) log.warn("Concealed error", new Exception(reply.cause())); event.reply(new JsonObject().put(STATUS, ERROR)); } } + } diff --git a/src/main/java/org/swisspush/redisques/handler/GetQueueItemsCountHandler.java b/src/main/java/org/swisspush/redisques/handler/GetQueueItemsCountHandler.java index 0a292f80..a63fa62a 100644 --- a/src/main/java/org/swisspush/redisques/handler/GetQueueItemsCountHandler.java +++ b/src/main/java/org/swisspush/redisques/handler/GetQueueItemsCountHandler.java @@ -5,8 +5,13 @@ import io.vertx.core.eventbus.Message; import io.vertx.core.json.JsonObject; import io.vertx.redis.client.Response; +import org.slf4j.Logger; -import static org.swisspush.redisques.util.RedisquesAPI.*; +import static org.slf4j.LoggerFactory.getLogger; +import static org.swisspush.redisques.util.RedisquesAPI.ERROR; +import static org.swisspush.redisques.util.RedisquesAPI.OK; +import static org.swisspush.redisques.util.RedisquesAPI.STATUS; +import static org.swisspush.redisques.util.RedisquesAPI.VALUE; /** * Class GetQueueItemsCountHandler. @@ -14,6 +19,8 @@ * @author https://github.com/mcweba [Marc-Andre Weber] */ public class GetQueueItemsCountHandler implements Handler> { + + private static final Logger log = getLogger(GetQueueItemsCountHandler.class); private final Message event; public GetQueueItemsCountHandler(Message event) { @@ -26,6 +33,7 @@ public void handle(AsyncResult reply) { Long queueItemCount = reply.result().toLong(); event.reply(new JsonObject().put(STATUS, OK).put(VALUE, queueItemCount)); } else { + log.warn("Concealed error", new Exception(reply.cause())); event.reply(new JsonObject().put(STATUS, ERROR)); } } diff --git a/src/main/java/org/swisspush/redisques/handler/GetQueueItemsHandler.java b/src/main/java/org/swisspush/redisques/handler/GetQueueItemsHandler.java index 4eb4b61d..770adbd7 100644 --- a/src/main/java/org/swisspush/redisques/handler/GetQueueItemsHandler.java +++ b/src/main/java/org/swisspush/redisques/handler/GetQueueItemsHandler.java @@ -1,14 +1,19 @@ package org.swisspush.redisques.handler; import io.vertx.core.AsyncResult; -import io.vertx.core.json.JsonArray; - -import static org.swisspush.redisques.util.RedisquesAPI.*; - import io.vertx.core.Handler; import io.vertx.core.eventbus.Message; +import io.vertx.core.json.JsonArray; import io.vertx.core.json.JsonObject; import io.vertx.redis.client.Response; +import org.slf4j.Logger; + +import static org.slf4j.LoggerFactory.getLogger; +import static org.swisspush.redisques.util.RedisquesAPI.ERROR; +import static org.swisspush.redisques.util.RedisquesAPI.INFO; +import static org.swisspush.redisques.util.RedisquesAPI.OK; +import static org.swisspush.redisques.util.RedisquesAPI.STATUS; +import static org.swisspush.redisques.util.RedisquesAPI.VALUE; /** * Class GetQueueItemsHandler. @@ -16,6 +21,8 @@ * @author baldim, https://github.com/mcweba [Marc-Andre Weber] */ public class GetQueueItemsHandler implements Handler> { + + private static final Logger log = getLogger(GetQueueItemsHandler.class); private final Message event; private final Long queueItemCount; @@ -39,7 +46,9 @@ public void handle(AsyncResult reply) { } event.reply(new JsonObject().put(STATUS, OK).put(VALUE, values).put(INFO, countInfo)); } else { + log.warn("Concealed error", new Exception(reply.cause())); event.reply(new JsonObject().put(STATUS, ERROR)); } } + } diff --git a/src/main/java/org/swisspush/redisques/handler/GetQueuesCountHandler.java b/src/main/java/org/swisspush/redisques/handler/GetQueuesCountHandler.java index d6737fec..2b241f41 100644 --- a/src/main/java/org/swisspush/redisques/handler/GetQueuesCountHandler.java +++ b/src/main/java/org/swisspush/redisques/handler/GetQueuesCountHandler.java @@ -5,8 +5,13 @@ import io.vertx.core.eventbus.Message; import io.vertx.core.json.JsonObject; import io.vertx.redis.client.Response; +import org.slf4j.Logger; -import static org.swisspush.redisques.util.RedisquesAPI.*; +import static org.slf4j.LoggerFactory.getLogger; +import static org.swisspush.redisques.util.RedisquesAPI.ERROR; +import static org.swisspush.redisques.util.RedisquesAPI.OK; +import static org.swisspush.redisques.util.RedisquesAPI.STATUS; +import static org.swisspush.redisques.util.RedisquesAPI.VALUE; /** * Class GetQueuesCountHandler. @@ -14,6 +19,8 @@ * @author https://github.com/mcweba [Marc-Andre Weber] */ public class GetQueuesCountHandler implements Handler> { + + private static final Logger log = getLogger(GetQueuesCountHandler.class); private final Message event; public GetQueuesCountHandler(Message event) { @@ -26,7 +33,9 @@ public void handle(AsyncResult reply) { Long queueCount = reply.result().toLong(); event.reply(new JsonObject().put(STATUS, OK).put(VALUE, queueCount)); } else { + log.warn("Concealed error", new Exception(reply.cause())); event.reply(new JsonObject().put(STATUS, ERROR)); } } + } diff --git a/src/main/java/org/swisspush/redisques/handler/GetQueuesHandler.java b/src/main/java/org/swisspush/redisques/handler/GetQueuesHandler.java index 1cf75857..3a794a83 100644 --- a/src/main/java/org/swisspush/redisques/handler/GetQueuesHandler.java +++ b/src/main/java/org/swisspush/redisques/handler/GetQueuesHandler.java @@ -6,19 +6,26 @@ import io.vertx.core.json.JsonArray; import io.vertx.core.json.JsonObject; import io.vertx.redis.client.Response; +import org.slf4j.Logger; import org.swisspush.redisques.util.HandlerUtil; import java.util.List; import java.util.Optional; import java.util.regex.Pattern; -import static org.swisspush.redisques.util.RedisquesAPI.*; +import static org.slf4j.LoggerFactory.getLogger; +import static org.swisspush.redisques.util.RedisquesAPI.ERROR; +import static org.swisspush.redisques.util.RedisquesAPI.OK; +import static org.swisspush.redisques.util.RedisquesAPI.QUEUES; +import static org.swisspush.redisques.util.RedisquesAPI.STATUS; +import static org.swisspush.redisques.util.RedisquesAPI.VALUE; /** * @author https://github.com/mcweba [Marc-Andre Weber] */ public class GetQueuesHandler implements Handler> { + private static final Logger log = getLogger(GetQueuesHandler.class); private final Message event; private final Optional filterPattern; private final boolean countOnly; @@ -42,6 +49,7 @@ public void handle(AsyncResult reply) { event.reply(new JsonObject().put(STATUS, OK).put(VALUE, jsonRes)); } } else { + log.warn("Concealed error", new Exception(reply.cause())); event.reply(new JsonObject().put(STATUS, ERROR)); } } diff --git a/src/main/java/org/swisspush/redisques/handler/GetQueuesItemsCountHandler.java b/src/main/java/org/swisspush/redisques/handler/GetQueuesItemsCountHandler.java index 9997bbdf..6f51dd1e 100644 --- a/src/main/java/org/swisspush/redisques/handler/GetQueuesItemsCountHandler.java +++ b/src/main/java/org/swisspush/redisques/handler/GetQueuesItemsCountHandler.java @@ -39,7 +39,8 @@ public GetQueuesItemsCountHandler( Message event, Optional filterPattern, String queuesPrefix, - RedisProvider redisProvider) { + RedisProvider redisProvider + ) { this.event = event; this.filterPattern = filterPattern; this.queuesPrefix = queuesPrefix; @@ -57,17 +58,18 @@ public void handle(AsyncResult handleQueues) { return; } - redisProvider.connection().onSuccess(conn -> { - List responses = queues.stream().map(queue -> conn.send(Request.cmd(Command.LLEN, queuesPrefix + queue)) - ).collect(Collectors.toList()); - CompositeFuture.all(responses).onFailure(throwable -> { - log.error("Unexepected queue length result"); + List responses = queues.stream() + .map(queue -> conn.send(Request.cmd(Command.LLEN, queuesPrefix + queue))) + .collect(Collectors.toList()); + CompositeFuture.all(responses).onFailure(ex -> { + log.error("Unexpected queue length result", new Exception(ex)); event.reply(new JsonObject().put(STATUS, ERROR)); }).onSuccess(compositeFuture -> { List queueLengthList = compositeFuture.list(); if (queueLengthList == null) { - log.error("Unexepected queue length result null"); + log.error("Unexpected queue length result null", + new Exception(compositeFuture.cause())); event.reply(new JsonObject().put(STATUS, ERROR)); return; } @@ -87,12 +89,13 @@ public void handle(AsyncResult handleQueues) { event.reply(new JsonObject().put(RedisquesAPI.STATUS, RedisquesAPI.OK) .put(QUEUES, result)); }); - }).onFailure(throwable -> { - log.warn("Redis: Failed to get queue length.", throwable); + }).onFailure(ex -> { + log.warn("Redis: Failed to get queue length.", new Exception(ex)); event.reply(new JsonObject().put(STATUS, ERROR)); }); } else { + log.warn("Concealed error", new Exception(handleQueues.cause())); event.reply(new JsonObject().put(STATUS, ERROR)); } } diff --git a/src/main/java/org/swisspush/redisques/handler/GetQueuesSpeedHandler.java b/src/main/java/org/swisspush/redisques/handler/GetQueuesSpeedHandler.java index 233fa9b4..faa7fb8e 100644 --- a/src/main/java/org/swisspush/redisques/handler/GetQueuesSpeedHandler.java +++ b/src/main/java/org/swisspush/redisques/handler/GetQueuesSpeedHandler.java @@ -1,18 +1,21 @@ package org.swisspush.redisques.handler; -import static org.swisspush.redisques.util.RedisquesAPI.ERROR; -import static org.swisspush.redisques.util.RedisquesAPI.STATUS; - import io.vertx.core.AsyncResult; import io.vertx.core.Handler; import io.vertx.core.eventbus.Message; import io.vertx.core.json.JsonObject; import io.vertx.redis.client.Response; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.swisspush.redisques.util.HandlerUtil; +import org.swisspush.redisques.util.QueueStatisticsCollector; + import java.util.List; import java.util.Optional; import java.util.regex.Pattern; -import org.swisspush.redisques.util.HandlerUtil; -import org.swisspush.redisques.util.QueueStatisticsCollector; + +import static org.swisspush.redisques.util.RedisquesAPI.ERROR; +import static org.swisspush.redisques.util.RedisquesAPI.STATUS; /** * Retrieves in it's AsyncResult handler the speed summary of the queues matching the given filter @@ -20,13 +23,16 @@ */ public class GetQueuesSpeedHandler implements Handler> { + private static final Logger log = LoggerFactory.getLogger(GetQueuesSpeedHandler.class); private final Message event; private final Optional filterPattern; private final QueueStatisticsCollector queueStatisticsCollector; - public GetQueuesSpeedHandler(Message event, - Optional filterPattern, - QueueStatisticsCollector queueStatisticsCollector) { + public GetQueuesSpeedHandler( + Message event, + Optional filterPattern, + QueueStatisticsCollector queueStatisticsCollector + ) { this.event = event; this.filterPattern = filterPattern; this.queueStatisticsCollector = queueStatisticsCollector; @@ -40,6 +46,7 @@ public void handle(AsyncResult handleQueues) { .filterByPattern(handleQueues.result(), filterPattern); queueStatisticsCollector.getQueuesSpeed(event, queues); } else { + log.warn("Concealed error", new Exception(handleQueues.cause())); event.reply(new JsonObject().put(STATUS, ERROR)); } } diff --git a/src/main/java/org/swisspush/redisques/handler/GetQueuesStatisticsHandler.java b/src/main/java/org/swisspush/redisques/handler/GetQueuesStatisticsHandler.java index 91f96794..2c55fc11 100644 --- a/src/main/java/org/swisspush/redisques/handler/GetQueuesStatisticsHandler.java +++ b/src/main/java/org/swisspush/redisques/handler/GetQueuesStatisticsHandler.java @@ -1,18 +1,21 @@ package org.swisspush.redisques.handler; -import static org.swisspush.redisques.util.RedisquesAPI.ERROR; -import static org.swisspush.redisques.util.RedisquesAPI.STATUS; - import io.vertx.core.AsyncResult; import io.vertx.core.Handler; import io.vertx.core.eventbus.Message; import io.vertx.core.json.JsonObject; import io.vertx.redis.client.Response; +import org.slf4j.Logger; +import org.swisspush.redisques.util.HandlerUtil; +import org.swisspush.redisques.util.QueueStatisticsCollector; + import java.util.List; import java.util.Optional; import java.util.regex.Pattern; -import org.swisspush.redisques.util.HandlerUtil; -import org.swisspush.redisques.util.QueueStatisticsCollector; + +import static org.slf4j.LoggerFactory.getLogger; +import static org.swisspush.redisques.util.RedisquesAPI.ERROR; +import static org.swisspush.redisques.util.RedisquesAPI.STATUS; /** * Retrieves in it's AsyncResult handler for all given queue names the queue statistics information @@ -20,13 +23,16 @@ */ public class GetQueuesStatisticsHandler implements Handler> { + private static final Logger log = getLogger(GetQueuesStatisticsHandler.class); private final Message event; private final Optional filterPattern; private final QueueStatisticsCollector queueStatisticsCollector; - public GetQueuesStatisticsHandler(Message event, - Optional filterPattern, - QueueStatisticsCollector queueStatisticsCollector) { + public GetQueuesStatisticsHandler( + Message event, + Optional filterPattern, + QueueStatisticsCollector queueStatisticsCollector + ) { this.event = event; this.filterPattern = filterPattern; this.queueStatisticsCollector = queueStatisticsCollector; @@ -39,7 +45,9 @@ public void handle(AsyncResult handleQueues) { .filterByPattern(handleQueues.result(), filterPattern); queueStatisticsCollector.getQueueStatistics(event, queues); } else { + log.warn("Concealed error", new Exception(handleQueues.cause())); event.reply(new JsonObject().put(STATUS, ERROR)); } } + } diff --git a/src/main/java/org/swisspush/redisques/handler/PutLockHandler.java b/src/main/java/org/swisspush/redisques/handler/PutLockHandler.java index 9247b1f5..0f733421 100644 --- a/src/main/java/org/swisspush/redisques/handler/PutLockHandler.java +++ b/src/main/java/org/swisspush/redisques/handler/PutLockHandler.java @@ -1,30 +1,39 @@ -package org.swisspush.redisques.handler; - -import io.vertx.core.AsyncResult; -import static org.swisspush.redisques.util.RedisquesAPI.*; -import io.vertx.core.Handler; -import io.vertx.core.eventbus.Message; -import io.vertx.core.json.JsonObject; -import io.vertx.redis.client.Response; - -/** - * Class PutLock. - * - * @author baldim - */ -public class PutLockHandler implements Handler> { - private final Message event; - - public PutLockHandler(Message event) { - this.event = event; - } - - @Override - public void handle(AsyncResult reply) { - if(reply.succeeded()){ - event.reply(new JsonObject().put(STATUS, OK)); - } else { - event.reply(new JsonObject().put(STATUS, ERROR)); - } - } -} +package org.swisspush.redisques.handler; + +import io.vertx.core.AsyncResult; +import io.vertx.core.Handler; +import io.vertx.core.eventbus.Message; +import io.vertx.core.json.JsonObject; +import io.vertx.redis.client.Response; +import org.slf4j.Logger; + +import static org.slf4j.LoggerFactory.getLogger; +import static org.swisspush.redisques.util.RedisquesAPI.ERROR; +import static org.swisspush.redisques.util.RedisquesAPI.OK; +import static org.swisspush.redisques.util.RedisquesAPI.STATUS; + +/** + * Class PutLock. + * + * @author baldim + */ +public class PutLockHandler implements Handler> { + + private static final Logger log = getLogger(PutLockHandler.class); + private final Message event; + + public PutLockHandler(Message event) { + this.event = event; + } + + @Override + public void handle(AsyncResult reply) { + if(reply.succeeded()){ + event.reply(new JsonObject().put(STATUS, OK)); + } else { + log.warn("Concealed error", new Exception(reply.cause())); + event.reply(new JsonObject().put(STATUS, ERROR)); + } + } + +} diff --git a/src/main/java/org/swisspush/redisques/handler/ReplaceQueueItemHandler.java b/src/main/java/org/swisspush/redisques/handler/ReplaceQueueItemHandler.java index 73307bba..f789db43 100644 --- a/src/main/java/org/swisspush/redisques/handler/ReplaceQueueItemHandler.java +++ b/src/main/java/org/swisspush/redisques/handler/ReplaceQueueItemHandler.java @@ -1,11 +1,16 @@ package org.swisspush.redisques.handler; import io.vertx.core.AsyncResult; -import static org.swisspush.redisques.util.RedisquesAPI.*; import io.vertx.core.Handler; import io.vertx.core.eventbus.Message; import io.vertx.core.json.JsonObject; import io.vertx.redis.client.Response; +import org.slf4j.Logger; + +import static org.slf4j.LoggerFactory.getLogger; +import static org.swisspush.redisques.util.RedisquesAPI.ERROR; +import static org.swisspush.redisques.util.RedisquesAPI.OK; +import static org.swisspush.redisques.util.RedisquesAPI.STATUS; /** * Class ReplaceQueueItemHandler. @@ -13,6 +18,8 @@ * @author baldim, https://github.com/mcweba [Marc-Andre Weber] */ public class ReplaceQueueItemHandler implements Handler> { + + private static final Logger log = getLogger(ReplaceQueueItemHandler.class); private final Message event; public ReplaceQueueItemHandler(Message event) { @@ -24,7 +31,9 @@ public void handle(AsyncResult reply) { if(reply.succeeded()){ event.reply(new JsonObject().put(STATUS, OK)); } else { + log.warn("Concealed error", new Exception(reply.cause())); event.reply(new JsonObject().put(STATUS, ERROR)); } } + }