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

davsclaus pushed a commit to branch camel-3.0.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-3.0.x by this push:
     new be73f4d  CAMEL-14361 Update to avoid reflection in creating http 
method (#3469)
be73f4d is described below

commit be73f4d60cf10dc5338657b376709bf48ca72dff
Author: Amos Feng <zf...@redhat.com>
AuthorDate: Thu Jan 9 15:39:10 2020 +0800

    CAMEL-14361 Update to avoid reflection in creating http method (#3469)
---
 .../apache/camel/component/http/HttpMethods.java   | 23 ++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git 
a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMethods.java
 
b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMethods.java
index 6302580..8b81704 100644
--- 
a/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMethods.java
+++ 
b/components/camel-http/src/main/java/org/apache/camel/component/http/HttpMethods.java
@@ -51,8 +51,27 @@ public enum HttpMethods implements Expression {
 
     public HttpRequestBase createMethod(final String url) {
         try {
-            return clazz.getDeclaredConstructor(String.class).newInstance(url);
-        } catch (Exception e) {
+            switch (this) {
+            case GET:
+                return new HttpGet(url);
+            case PATCH:
+                return new HttpPatch(url);
+            case POST:
+                return new HttpPost(url);
+            case PUT:
+                return new HttpPut(url);
+            case DELETE:
+                return new HttpDelete(url);
+            case HEAD:
+                return new HttpHead(url);
+            case OPTIONS:
+                return new HttpOptions(url);
+            case TRACE:
+                return new HttpTrace(url);
+            default:
+                throw new RuntimeException("no such method " + this);
+            }
+        } catch (IllegalArgumentException e) {
             throw new RuntimeException(e);
         }
     }

Reply via email to