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
commit cd409f655f7bbda2a15a06389050eb92f62929e5 Author: Pascal Schumacher <[email protected]> AuthorDate: Fri Jan 10 05:14:43 2020 +0100 Clean-ups following "CAMEL-14361: Update to avoid reflection in creating http method" (#3471) * CAMEL-14361: Update to avoid reflection in creating http method Remove unnecessary wrapping of IllegalArgumentException in RuntimeException. * CAMEL-14361: Update to avoid reflection in creating http method Remove unused clazz field. --- .../apache/camel/component/http/HttpMethods.java | 44 ++++++++++------------ 1 file changed, 19 insertions(+), 25 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 8b81704..554de0f 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 @@ -41,38 +41,32 @@ public enum HttpMethods implements Expression { OPTIONS(HttpOptions.class), TRACE(HttpTrace.class); - final Class<? extends HttpRequestBase> clazz; final boolean entity; HttpMethods(Class<? extends HttpRequestBase> clazz) { - this.clazz = clazz; entity = HttpEntityEnclosingRequestBase.class.isAssignableFrom(clazz); } public HttpRequestBase createMethod(final String url) { - try { - 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); + 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); } }
