Skip to content

Commit

Permalink
RedisStorage.cleanup() NumberFormatException if caller didn't assign one
Browse files Browse the repository at this point in the history
  • Loading branch information
Xin Zheng committed Jun 5, 2024
1 parent 90ee2fc commit b39e1ac
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/java/org/swisspush/reststorage/RestStorageHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.vertx.ext.web.Router;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.handler.BasicAuthHandler;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.swisspush.reststorage.exception.RestStorageExceptionFactory;
import org.swisspush.reststorage.util.*;
Expand Down Expand Up @@ -45,6 +46,7 @@ public class RestStorageHandler implements Handler<HttpServerRequest> {
private final boolean return200onDeleteNonExisting;
private final DecimalFormat decimalFormat;
private final Integer maxStorageExpandSubresources;
private final long resourceCleanupAmount;

public RestStorageHandler(
Vertx vertx,
Expand All @@ -62,6 +64,7 @@ public RestStorageHandler(
this.rejectStorageWriteOnLowMemory = config.isRejectStorageWriteOnLowMemory();
this.return200onDeleteNonExisting = config.isReturn200onDeleteNonExisting();
this.maxStorageExpandSubresources = config.getMaxStorageExpandSubresources();
this.resourceCleanupAmount = config.getResourceCleanupAmount();

this.decimalFormat = new DecimalFormat();
this.decimalFormat.setMaximumFractionDigits(1);
Expand Down Expand Up @@ -127,7 +130,15 @@ private void cleanup(RoutingContext ctx) {
ctx.response().end();
});
pump.start();
}, ctx.request().params().get("cleanupResourcesAmount"));
}, getCleanupResourcesAmountContextOrConfig(ctx));
}

private String getCleanupResourcesAmountContextOrConfig(RoutingContext ctx) {
String cleanupResourcesAmount = ctx.request().getParam("cleanupResourcesAmount");
if (StringUtils.isEmpty(cleanupResourcesAmount)) {
cleanupResourcesAmount = String.valueOf(this.resourceCleanupAmount);
}
return cleanupResourcesAmount;
}

private void getResourceNotFound(RoutingContext ctx) {
Expand Down

0 comments on commit b39e1ac

Please sign in to comment.