This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 7e0dedbec2e CAMEL-20163: cleanup parsing HTTP status range 
(camel-vertx-http)
7e0dedbec2e is described below

commit 7e0dedbec2e99e8e1f749ecf57124820e60d142f
Author: Otavio Rodolfo Piske <angusyo...@gmail.com>
AuthorDate: Thu Nov 30 18:37:01 2023 -0300

    CAMEL-20163: cleanup parsing HTTP status range (camel-vertx-http)
---
 .../camel/component/vertx/http/VertxHttpEndpoint.java    | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git 
a/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpEndpoint.java
 
b/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpEndpoint.java
index 8d7170915b2..dcdb4bf47b7 100644
--- 
a/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpEndpoint.java
+++ 
b/components/camel-vertx/camel-vertx-http/src/main/java/org/apache/camel/component/vertx/http/VertxHttpEndpoint.java
@@ -31,6 +31,7 @@ import org.apache.camel.http.base.HttpHelper;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.support.DefaultEndpoint;
+import org.apache.camel.support.http.HttpUtil;
 import org.apache.camel.support.jsse.SSLContextParameters;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.StringHelper;
@@ -60,18 +61,23 @@ public class VertxHttpEndpoint extends DefaultEndpoint {
     @Override
     protected void doInit() throws Exception {
         String range = configuration.getOkStatusCodeRange();
+        parseStatusRange(range);
+    }
+
+    private void parseStatusRange(String range) {
         if (!range.contains(",")) {
-            // default is 200-299 so lets optimize for this
-            if (range.contains("-")) {
-                minOkRange = Integer.parseInt(StringHelper.before(range, "-"));
-                maxOkRange = Integer.parseInt(StringHelper.after(range, "-"));
-            } else {
+            if (!HttpUtil.parseStatusRange(range, this::setRanges)) {
                 minOkRange = Integer.parseInt(range);
                 maxOkRange = minOkRange;
             }
         }
     }
 
+    private void setRanges(int minOkRange, int maxOkRange) {
+        this.minOkRange = minOkRange;
+        this.maxOkRange = maxOkRange;
+    }
+
     @Override
     public Producer createProducer() throws Exception {
         return new VertxHttpProducer(this);

Reply via email to