diff options
author | Harald Musum <musum@yahooinc.com> | 2023-10-08 20:48:50 +0200 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2023-10-08 20:48:50 +0200 |
commit | da4280049664b54b3e09a0bf0abbe51c870f7d55 (patch) | |
tree | bdf82298a93d765e397170aad2448cd163886ca6 /controller-server/src/main/java/com | |
parent | 29dc9dbedcc97db72ea5b026bcc309a75ac9872d (diff) |
Urlencode correctly, fix handling of missing separator
Diffstat (limited to 'controller-server/src/main/java/com')
-rw-r--r-- | controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/pricing/PricingApiHandler.java | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/pricing/PricingApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/pricing/PricingApiHandler.java index 92cd9031a49..a438a9c33e0 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/pricing/PricingApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/pricing/PricingApiHandler.java @@ -17,7 +17,6 @@ import com.yahoo.text.Text; import com.yahoo.vespa.hosted.controller.Controller; import com.yahoo.vespa.hosted.controller.api.integration.billing.Plan; import com.yahoo.vespa.hosted.controller.api.integration.pricing.PriceInformation; -import com.yahoo.vespa.hosted.controller.api.integration.pricing.PricingController; import com.yahoo.vespa.hosted.controller.api.integration.pricing.PricingInfo; import com.yahoo.vespa.hosted.controller.restapi.ErrorResponses; import com.yahoo.yolean.Exceptions; @@ -46,8 +45,8 @@ import static java.nio.charset.StandardCharsets.UTF_8; @SuppressWarnings("unused") // Handler public class PricingApiHandler extends ThreadedHttpRequestHandler { - private final static Logger log = Logger.getLogger(PricingApiHandler.class.getName()); - private static final BigDecimal SCALED_ZERO = new BigDecimal("0.00"); + private static final Logger log = Logger.getLogger(PricingApiHandler.class.getName()); + private static final BigDecimal SCALED_ZERO = BigDecimal.ZERO.setScale(2); private final Controller controller; @@ -138,13 +137,10 @@ public class PricingApiHandler extends ThreadedHttpRequestHandler { return new ClusterResources(nodes, 1, nodeResources); } - private static String getKeyAndValue(String element, int index) { - return element.substring(0, index); - } - private List<Pair<String, String>> keysAndValues(String[] elements) { return Arrays.stream(elements).map(element -> { var index = element.indexOf("="); + if (index <= 0 ) throw new IllegalArgumentException("Error in query parameter, expected '=' between key and value: " + element); return new Pair<>(element.substring(0, index), element.substring(index + 1)); }) .collect(Collectors.toList()); |