diff --git a/src/main/java/org/swisspush/redisques/handler/RedisquesHttpRequestHandler.java b/src/main/java/org/swisspush/redisques/handler/RedisquesHttpRequestHandler.java index 3991431..b1a71ac 100644 --- a/src/main/java/org/swisspush/redisques/handler/RedisquesHttpRequestHandler.java +++ b/src/main/java/org/swisspush/redisques/handler/RedisquesHttpRequestHandler.java @@ -22,7 +22,6 @@ import org.swisspush.redisques.QueueStatsService; import org.swisspush.redisques.QueueStatsService.GetQueueStatsMentor; import org.swisspush.redisques.exception.RedisQuesExceptionFactory; -import org.swisspush.redisques.util.DequeueStatistic; import org.swisspush.redisques.util.DequeueStatisticCollector; import org.swisspush.redisques.util.QueueStatisticsCollector; import org.swisspush.redisques.util.RedisquesAPI; @@ -30,6 +29,7 @@ import org.swisspush.redisques.util.Result; import org.swisspush.redisques.util.StatusCode; +import javax.annotation.Nullable; import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.util.Date; @@ -878,13 +878,17 @@ private void bulkDeleteQueues(RoutingContext ctx) { } } - private void respondWith(StatusCode statusCode, String responseMessage, HttpServerRequest request) { + private void respondWith(StatusCode statusCode, @Nullable String responseMessage, HttpServerRequest request) { final HttpServerResponse response = request.response(); log.info("Responding with status code {} and message '{}' to request '{}'", statusCode, responseMessage, request.uri()); response.setStatusCode(statusCode.getStatusCode()); response.setStatusMessage(statusCode.getStatusMessage()); response.putHeader(CONTENT_TYPE, TEXT_PLAIN); - response.end(responseMessage); + if(responseMessage != null) { + response.end(responseMessage); + } else { + response.end(); + } } private void respondWith(StatusCode statusCode, HttpServerRequest request) { diff --git a/src/test/java/org/swisspush/redisques/handler/RedisquesHttpRequestHandlerTest.java b/src/test/java/org/swisspush/redisques/handler/RedisquesHttpRequestHandlerTest.java index 565e7f4..b3384e7 100644 --- a/src/test/java/org/swisspush/redisques/handler/RedisquesHttpRequestHandlerTest.java +++ b/src/test/java/org/swisspush/redisques/handler/RedisquesHttpRequestHandlerTest.java @@ -709,6 +709,11 @@ public void addQueueItemInvalidBody(TestContext context) { assertKeyCount(context, getQueuesRedisKeyPrefix(), 0); context.assertEquals(0L, jedis.llen(getQueuesRedisKeyPrefix() + queueName)); + // this body creates a NullpointerException because there is no header property + given().body(configurationValid).when().post("/queuing/queues/" + queueName + "/").then().assertThat().statusCode(400); + assertKeyCount(context, getQueuesRedisKeyPrefix(), 0); + context.assertEquals(0L, jedis.llen(getQueuesRedisKeyPrefix() + queueName)); + async.complete(); }