camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/2] camel git commit: CAMEL-6707: fix issues reported by @davsclaus
Date Fri, 22 Apr 2016 06:29:59 GMT
Repository: camel
Updated Branches:
  refs/heads/master 2bd185e92 -> e6da66a69


CAMEL-6707: fix issues reported by @davsclaus


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e6da66a6
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e6da66a6
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e6da66a6

Branch: refs/heads/master
Commit: e6da66a69840d8aa5ab1926974a92b779f90c868
Parents: 6a1f84e
Author: Arnaud Deprez <arnaud.deprez@lampiris.be>
Authored: Thu Apr 21 22:13:03 2016 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Apr 22 07:44:45 2016 +0200

----------------------------------------------------------------------
 .../websocket/CamelWebSocketServlet.java        |  8 +--
 .../apache/camel/http/common/CamelServlet.java  | 53 +++++++-------
 .../camel/http/common/DefaultHttpBinding.java   | 62 ++++++++++------
 .../camel/http/common/HttpCommonComponent.java  |  1 +
 .../camel/http/common/HttpCommonEndpoint.java   | 16 +++--
 .../jetty/CamelContinuationServlet.java         | 23 +++---
 .../component/jetty/JettyHttpComponent.java     | 76 ++++++++++++++------
 .../jetty/ExplicitJettyAsyncRouteTest.java      |  2 +-
 ...pHttpMessageFormUrlEncodedFalseBodyTest.java |  6 +-
 .../component/jetty/HttpBridgeRouteTest.java    |  4 +-
 .../component/jetty/HttpsAsyncRouteTest.java    | 16 ++---
 .../camel/component/jetty/HttpsRouteTest.java   | 20 +++---
 .../component/servlet/ServletComponent.java     | 17 ++---
 .../component/servlet/ServletEndpoint.java      |  6 +-
 .../servlet/ServletAsyncArquillianTest.java     | 72 +++++++++++--------
 15 files changed, 227 insertions(+), 155 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e6da66a6/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/CamelWebSocketServlet.java
----------------------------------------------------------------------
diff --git a/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/CamelWebSocketServlet.java
b/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/CamelWebSocketServlet.java
index 2a84a73..9ddb21a 100644
--- a/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/CamelWebSocketServlet.java
+++ b/components/camel-atmosphere-websocket/src/main/java/org/apache/camel/component/atmosphere/websocket/CamelWebSocketServlet.java
@@ -16,14 +16,14 @@
  */
 package org.apache.camel.component.atmosphere.websocket;
 
-import org.apache.camel.component.servlet.CamelHttpTransportServlet;
-import org.apache.camel.http.common.HttpConsumer;
-
+import java.io.IOException;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
+
+import org.apache.camel.component.servlet.CamelHttpTransportServlet;
+import org.apache.camel.http.common.HttpConsumer;
 
 /**
  * This servlet is used to add some websocket specific handling at the moment.

http://git-wip-us.apache.org/repos/asf/camel/blob/e6da66a6/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java
b/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java
index 382a6a4..ed94745 100644
--- a/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/CamelServlet.java
@@ -16,6 +16,18 @@
  */
 package org.apache.camel.http.common;
 
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import javax.servlet.AsyncContext;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.RuntimeCamelException;
@@ -24,25 +36,12 @@ import org.apache.camel.util.ObjectHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.servlet.AsyncContext;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Optional;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
 /**
  * A servlet to use as a Camel route as entry.
  */
 public class CamelServlet extends HttpServlet {
-    private static final long serialVersionUID = -7061982839117697829L;
     public static final String ASYNC_PARAM = "async";
+    private static final long serialVersionUID = -7061982839117697829L;
     protected final Logger log = LoggerFactory.getLogger(getClass());
     
     /**
@@ -50,7 +49,7 @@ public class CamelServlet extends HttpServlet {
      *  sure that it is already set via the init method
      */
     private String servletName;
-    private boolean async = false;
+    private boolean async;
 
     private ServletResolveConsumerStrategy servletResolveConsumerStrategy = new HttpServletResolveConsumerStrategy();
     private final ConcurrentMap<String, HttpConsumer> consumers = new ConcurrentHashMap<String,
HttpConsumer>();
@@ -59,9 +58,9 @@ public class CamelServlet extends HttpServlet {
     public void init(ServletConfig config) throws ServletException {
         super.init(config);
         this.servletName = config.getServletName();
-        this.async = Optional.ofNullable(config.getInitParameter(ASYNC_PARAM))
-            .map(ObjectHelper::toBoolean)
-            .orElse(Boolean.FALSE);
+
+        final String asyncParam = config.getInitParameter(ASYNC_PARAM);
+        this.async = asyncParam == null ? false : ObjectHelper.toBoolean(asyncParam);
         log.trace("servlet '{}' initialized with: async={}", new Object[]{servletName, async});
     }
 
@@ -71,13 +70,12 @@ public class CamelServlet extends HttpServlet {
             final AsyncContext context = req.startAsync();
             //run async
             context.start(() -> doServiceAsync(context));
-        }
-        else {
+        } else {
             doService(req, resp);
         }
     }
 
-	/**
+    /**
      * This is used to handle request asynchronously
      * @param context the {@link AsyncContext}
      */
@@ -86,25 +84,22 @@ public class CamelServlet extends HttpServlet {
         final HttpServletResponse response = (HttpServletResponse) context.getResponse();
         try {
             doService(request, response);
-        }
-        //An error shouldn't occur as we should handle most of error in doService
-        catch (Exception e) {
+        } catch (Exception e) {
+            //An error shouldn't occur as we should handle most of error in doService
             log.error("Error processing request", e);
             try {
                 response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-            }
-            catch (Exception e1) {
+            } catch (Exception e1) {
                 log.debug("Cannot send reply to client!", e1);
             }
             //Need to wrap it in RuntimeException as it occurs in a Runnable
             throw new RuntimeCamelException(e);
-        }
-        finally {
+        } finally {
             context.complete();
         }
     }
 
-	/**
+    /**
      * This is the logical implementation to handle request with {@link CamelServlet}
      * This is where most exceptions should be handled
      *

http://git-wip-us.apache.org/repos/asf/camel/blob/e6da66a6/components/camel-http-common/src/main/java/org/apache/camel/http/common/DefaultHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/DefaultHttpBinding.java
b/components/camel-http-common/src/main/java/org/apache/camel/http/common/DefaultHttpBinding.java
index 1f190fe..828d90c 100644
--- a/components/camel-http-common/src/main/java/org/apache/camel/http/common/DefaultHttpBinding.java
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/DefaultHttpBinding.java
@@ -16,7 +16,34 @@
  */
 package org.apache.camel.http.common;
 
-import org.apache.camel.*;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.TimeZone;
+import javax.activation.DataHandler;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.InvalidPayloadException;
+import org.apache.camel.Message;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.StreamCache;
 import org.apache.camel.converter.stream.CachedOutputStream;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.util.GZIPHelper;
@@ -26,15 +53,6 @@ import org.apache.camel.util.ObjectHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.activation.DataHandler;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.*;
-import java.net.URLDecoder;
-import java.text.SimpleDateFormat;
-import java.util.*;
-
 /**
  * Binding between {@link HttpMessage} and {@link HttpServletResponse}.
  * <p/>
@@ -92,11 +110,11 @@ public class DefaultHttpBinding implements HttpBinding {
             readHeaders(request, message);
         }
         if (mapHttpMessageFormUrlEncodedBody) {
-        	try {
-				readFormUrlEncodedBody(request, message);
-			} catch (UnsupportedEncodingException e) {
-	            throw new RuntimeCamelException("Cannot read Form URL encoded body due " + e.getMessage(),
e);
-			}
+            try {
+                readFormUrlEncodedBody(request, message);
+            } catch (UnsupportedEncodingException e) {
+                throw new RuntimeCamelException("Cannot read Form URL encoded body due "
+ e.getMessage(), e);
+            }
         }
 
         // populate the headers from the request
@@ -212,9 +230,9 @@ public class DefaultHttpBinding implements HttpBinding {
         }
     }
 
-	protected void readFormUrlEncodedBody(HttpServletRequest request, HttpMessage message) throws
UnsupportedEncodingException {
+    protected void readFormUrlEncodedBody(HttpServletRequest request, HttpMessage message)
throws UnsupportedEncodingException {
         LOG.trace("readFormUrlEncodedBody {}", request);
-		// should we extract key=value pairs from form bodies (application/x-www-form-urlencoded)
+        // should we extract key=value pairs from form bodies (application/x-www-form-urlencoded)
         // and map those to Camel headers
         if (mapHttpMessageBody && mapHttpMessageHeaders) {
             LOG.trace("HTTP method {} with Content-Type {}", request.getMethod(), request.getContentType());
@@ -260,16 +278,16 @@ public class DefaultHttpBinding implements HttpBinding {
                 }
             }
         }
-	}
+    }
 
     private String getRawPath(HttpServletRequest request) {
         String uri = request.getRequestURI();
-		/**
+        /**
          * In async case, it seems that request.getContextPath() can return null
          * @see https://dev.eclipse.org/mhonarc/lists/jetty-users/msg04669.html
          */
-        String contextPath = Optional.ofNullable(request.getContextPath()).orElse("");
-        String servletPath = Optional.ofNullable(request.getServletPath()).orElse("");
+        String contextPath = request.getContextPath() == null ? "" : request.getContextPath();
+        String servletPath = request.getServletPath() == null ? "" : request.getServletPath();
         return uri.substring(contextPath.length() + servletPath.length());
     }
 
@@ -619,7 +637,7 @@ public class DefaultHttpBinding implements HttpBinding {
         this.mapHttpMessageFormUrlEncodedBody = mapHttpMessageFormUrlEncodedBody;
     }
 
-	protected static SimpleDateFormat getHttpDateFormat() {
+    protected static SimpleDateFormat getHttpDateFormat() {
         SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.US);
         dateFormat.setTimeZone(TIME_ZONE_GMT);
         return dateFormat;

http://git-wip-us.apache.org/repos/asf/camel/blob/e6da66a6/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonComponent.java
b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonComponent.java
index a99472e..189c269 100644
--- a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonComponent.java
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonComponent.java
@@ -86,4 +86,5 @@ public abstract class HttpCommonComponent extends HeaderFilterStrategyComponent
     public void setAllowJavaSerializedObject(boolean allowJavaSerializedObject) {
         this.allowJavaSerializedObject = allowJavaSerializedObject;
     }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/e6da66a6/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java
b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java
index 9007322..99f03ea 100644
--- a/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java
+++ b/components/camel-http-common/src/main/java/org/apache/camel/http/common/HttpCommonEndpoint.java
@@ -16,12 +16,16 @@
  */
 package org.apache.camel.http.common;
 
-import org.apache.camel.impl.DefaultEndpoint;
-import org.apache.camel.spi.*;
-
 import java.net.URI;
 import java.net.URISyntaxException;
 
+import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spi.HeaderFilterStrategy;
+import org.apache.camel.spi.HeaderFilterStrategyAware;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+
 public abstract class HttpCommonEndpoint extends DefaultEndpoint implements HeaderFilterStrategyAware
{
 
     // Note: all options must be documented with description in annotations so extended components
can access the documentation
@@ -43,9 +47,9 @@ public abstract class HttpCommonEndpoint extends DefaultEndpoint implements
Head
                     + " You may also set the option throwExceptionOnFailure to be false to
let the HttpProducer send all the fault response back.")
     boolean bridgeEndpoint;
     @UriParam(label = "producer",
-            description = "If the option is true, HttpProducer will set the Host header to
the value contained in the current exchange Host header, " +
-                    "useful in reverse proxy applications where you want the Host header
received by the downstream server to reflect the URL called by the upstream client, " +
-                    "this allows applications which use the Host header to generate accurate
URL's for a proxied service")
+            description = "If the option is true, HttpProducer will set the Host header to
the value contained in the current exchange Host header, "
+                + "useful in reverse proxy applications where you want the Host header received
by the downstream server to reflect the URL called by the upstream client, "
+                + "this allows applications which use the Host header to generate accurate
URL's for a proxied service")
     boolean preserveHostHeader;
     @UriParam(label = "consumer",
             description = "Whether or not the consumer should try to find a target consumer
by matching the URI prefix if no exact match is found.")

http://git-wip-us.apache.org/repos/asf/camel/blob/e6da66a6/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
index d9abfe2..f1299f4 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/CamelContinuationServlet.java
@@ -16,24 +16,29 @@
  */
 package org.apache.camel.component.jetty;
 
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import org.apache.camel.AsyncCallback;
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
-import org.apache.camel.http.common.*;
+import org.apache.camel.http.common.CamelServlet;
+import org.apache.camel.http.common.HttpCommonEndpoint;
+import org.apache.camel.http.common.HttpConstants;
+import org.apache.camel.http.common.HttpConsumer;
+import org.apache.camel.http.common.HttpHelper;
+import org.apache.camel.http.common.HttpMessage;
 import org.apache.camel.impl.DefaultExchange;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.UnsafeUriCharactersEncoder;
 import org.eclipse.jetty.continuation.Continuation;
 import org.eclipse.jetty.continuation.ContinuationSupport;
 
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
 /**
  * Servlet which leverage <a href="http://wiki.eclipse.org/Jetty/Feature/Continuations">Jetty
Continuations</a>.
  *

http://git-wip-us.apache.org/repos/asf/camel/blob/e6da66a6/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
index 828514b..7b3e7bf 100644
--- a/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
+++ b/components/camel-jetty-common/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
@@ -16,16 +16,61 @@
  */
 package org.apache.camel.component.jetty;
 
-import org.apache.camel.*;
-import org.apache.camel.http.common.*;
-import org.apache.camel.spi.*;
-import org.apache.camel.util.*;
+import java.io.File;
+import java.io.IOException;
+import java.io.Writer;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.security.GeneralSecurityException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import javax.management.MBeanServer;
+import javax.servlet.Filter;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Consumer;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Processor;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.http.common.CamelServlet;
+import org.apache.camel.http.common.HttpBinding;
+import org.apache.camel.http.common.HttpCommonComponent;
+import org.apache.camel.http.common.HttpCommonEndpoint;
+import org.apache.camel.http.common.HttpConfiguration;
+import org.apache.camel.http.common.HttpConsumer;
+import org.apache.camel.http.common.HttpRestServletResolveConsumerStrategy;
+import org.apache.camel.http.common.UrlRewrite;
+import org.apache.camel.spi.HeaderFilterStrategy;
+import org.apache.camel.spi.ManagementAgent;
+import org.apache.camel.spi.ManagementStrategy;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.RestApiConsumerFactory;
+import org.apache.camel.spi.RestConfiguration;
+import org.apache.camel.spi.RestConsumerFactory;
+import org.apache.camel.util.FileUtil;
+import org.apache.camel.util.HostUtils;
+import org.apache.camel.util.IntrospectionSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.URISupport;
+import org.apache.camel.util.UnsafeUriCharactersEncoder;
 import org.apache.camel.util.jsse.SSLContextParameters;
 import org.eclipse.jetty.client.HttpClient;
 import org.eclipse.jetty.http.HttpStatus;
 import org.eclipse.jetty.jmx.MBeanContainer;
-import org.eclipse.jetty.server.*;
+import org.eclipse.jetty.server.AbstractConnector;
+import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.Response;
+import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.handler.ContextHandlerCollection;
 import org.eclipse.jetty.server.handler.ErrorHandler;
 import org.eclipse.jetty.server.handler.HandlerCollection;
@@ -43,21 +88,6 @@ import org.eclipse.jetty.util.thread.ThreadPool;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.management.MBeanServer;
-import javax.servlet.Filter;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.File;
-import java.io.IOException;
-import java.io.Writer;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.security.GeneralSecurityException;
-import java.util.*;
-
 /**
  * An HttpComponent which starts an embedded Jetty for to handle consuming from
  * the http endpoints.
@@ -152,7 +182,7 @@ public abstract class JettyHttpComponent extends HttpCommonComponent implements
         Integer httpClientMinThreads = getAndRemoveParameter(parameters, "httpClientMinThreads",
Integer.class, this.httpClientMinThreads);
         Integer httpClientMaxThreads = getAndRemoveParameter(parameters, "httpClientMaxThreads",
Integer.class, this.httpClientMaxThreads);
         HttpClient httpClient = resolveAndRemoveReferenceParameter(parameters, "httpClient",
HttpClient.class);
-        Optional<Boolean> async = Optional.ofNullable(getAndRemoveParameter(parameters,
"async", Boolean.class));
+        Boolean async = getAndRemoveParameter(parameters, "async", Boolean.class);
 
         // extract httpClient. parameters
         Map<String, Object> httpClientParameters = IntrospectionSupport.extractProperties(parameters,
"httpClient.");
@@ -174,7 +204,9 @@ public abstract class JettyHttpComponent extends HttpCommonComponent implements
         endpointUri = new URI(scheme + ":" + endpointUri);
 
         JettyHttpEndpoint endpoint = createEndpoint(endpointUri, httpUri);
-        async.ifPresent(endpoint::setAsync);
+        if (async != null) {
+            endpoint.setAsync(async);
+        }
 
         if (headerFilterStrategy != null) {
             endpoint.setHeaderFilterStrategy(headerFilterStrategy);

http://git-wip-us.apache.org/repos/asf/camel/blob/e6da66a6/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/ExplicitJettyAsyncRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/ExplicitJettyAsyncRouteTest.java
b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/ExplicitJettyAsyncRouteTest.java
index 63fba47..8b36461 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/ExplicitJettyAsyncRouteTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/ExplicitJettyAsyncRouteTest.java
@@ -16,12 +16,12 @@
  */
 package org.apache.camel.component.jetty;
 
+import javax.servlet.http.HttpServletRequest;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.junit.Test;
 
-import javax.servlet.http.HttpServletRequest;
 
 /**
  * Unit test for wiki demonstration.

http://git-wip-us.apache.org/repos/asf/camel/blob/e6da66a6/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBindingMapHttpMessageFormUrlEncodedFalseBodyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBindingMapHttpMessageFormUrlEncodedFalseBodyTest.java
b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBindingMapHttpMessageFormUrlEncodedFalseBodyTest.java
index 0a99d9b..8f3df8d 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBindingMapHttpMessageFormUrlEncodedFalseBodyTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBindingMapHttpMessageFormUrlEncodedFalseBodyTest.java
@@ -29,9 +29,9 @@ public class HttpBindingMapHttpMessageFormUrlEncodedFalseBodyTest extends
BaseJe
     
     @Test
     public void testSendToJetty() throws Exception {
-    	Map<String,Object> map = new HashMap<String,Object>();
-    	map.put("content-type", "application/x-www-form-urlencoded");
-    	map.put(Exchange.HTTP_METHOD, HttpMethods.POST);
+        Map<String, Object> map = new HashMap<>();
+        map.put("content-type", "application/x-www-form-urlencoded");
+        map.put(Exchange.HTTP_METHOD, HttpMethods.POST);
         template.requestBodyAndHeaders("http://localhost:{{port}}/myapp/myservice?query1=a&query2=b",
"b1=x&b2=y", map);
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/e6da66a6/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBridgeRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBridgeRouteTest.java
b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBridgeRouteTest.java
index edfbd3a..6b9cf2a 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBridgeRouteTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpBridgeRouteTest.java
@@ -16,14 +16,14 @@
  */
 package org.apache.camel.component.jetty;
 
+import java.io.ByteArrayInputStream;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.builder.RouteBuilder;
 import org.junit.Test;
 
-import java.io.ByteArrayInputStream;
-
 public class HttpBridgeRouteTest extends BaseJettyTest {
 
     protected int port1;

http://git-wip-us.apache.org/repos/asf/camel/blob/e6da66a6/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpsAsyncRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpsAsyncRouteTest.java
b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpsAsyncRouteTest.java
index 6e3041b..a9e986e 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpsAsyncRouteTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpsAsyncRouteTest.java
@@ -16,6 +16,14 @@
  */
 package org.apache.camel.component.jetty;
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.SocketException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
@@ -27,14 +35,6 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.SocketException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
 
 public class HttpsAsyncRouteTest extends HttpsRouteTest {
 

http://git-wip-us.apache.org/repos/asf/camel/blob/e6da66a6/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpsRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpsRouteTest.java
b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpsRouteTest.java
index 9a3e04b..3403897 100644
--- a/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpsRouteTest.java
+++ b/components/camel-jetty9/src/test/java/org/apache/camel/component/jetty/HttpsRouteTest.java
@@ -16,6 +16,16 @@
  */
 package org.apache.camel.component.jetty;
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.SocketException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
@@ -28,16 +38,6 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.SocketException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
 public class HttpsRouteTest extends BaseJettyTest {
 
     public static final String NULL_VALUE_MARKER = CamelTestSupport.class.getCanonicalName();

http://git-wip-us.apache.org/repos/asf/camel/blob/e6da66a6/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java
b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java
index 2a16ebf..161c275 100644
--- a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java
+++ b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java
@@ -16,6 +16,11 @@
  */
 package org.apache.camel.component.servlet;
 
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
 import org.apache.camel.CamelContext;
 import org.apache.camel.Consumer;
 import org.apache.camel.Endpoint;
@@ -32,12 +37,6 @@ import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.URISupport;
 import org.apache.camel.util.UnsafeUriCharactersEncoder;
 
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Optional;
-
 public class ServletComponent extends HttpCommonComponent implements RestConsumerFactory,
RestApiConsumerFactory {
 
     private String servletName = "CamelServlet";
@@ -62,7 +61,7 @@ public class ServletComponent extends HttpCommonComponent implements RestConsume
         String servletName = getAndRemoveParameter(parameters, "servletName", String.class,
getServletName());
         String httpMethodRestrict = getAndRemoveParameter(parameters, "httpMethodRestrict",
String.class);
         HeaderFilterStrategy headerFilterStrategy = resolveAndRemoveReferenceParameter(parameters,
"headerFilterStrategy", HeaderFilterStrategy.class);
-        Optional<Boolean> async = Optional.ofNullable(getAndRemoveParameter(parameters,
"async", Boolean.class));
+        Boolean async = getAndRemoveParameter(parameters, "async", Boolean.class);
 
         if (lenientContextPath()) {
             // the uri must have a leading slash for the context-path matching to work with
servlet, and it can be something people
@@ -82,7 +81,9 @@ public class ServletComponent extends HttpCommonComponent implements RestConsume
 
         ServletEndpoint endpoint = createServletEndpoint(uri, this, httpUri);
         endpoint.setServletName(servletName);
-        async.ifPresent(endpoint::setAsync);
+        if (async != null) {
+            endpoint.setAsync(async);
+        }
         if (headerFilterStrategy != null) {
             endpoint.setHeaderFilterStrategy(headerFilterStrategy);
         } else {

http://git-wip-us.apache.org/repos/asf/camel/blob/e6da66a6/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java
b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java
index a22ffdb..5beefc3 100644
--- a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java
+++ b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletEndpoint.java
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.component.servlet;
 
+import java.net.URI;
+import java.net.URISyntaxException;
+
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
@@ -25,9 +28,6 @@ import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriPath;
 
-import java.net.URI;
-import java.net.URISyntaxException;
-
 /**
  * To use a HTTP Servlet as entry for Camel routes when running in a servlet container.
  */

http://git-wip-us.apache.org/repos/asf/camel/blob/e6da66a6/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletAsyncArquillianTest.java
----------------------------------------------------------------------
diff --git a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletAsyncArquillianTest.java
b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletAsyncArquillianTest.java
index 8ce0d98..8d50058 100644
--- a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletAsyncArquillianTest.java
+++ b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/ServletAsyncArquillianTest.java
@@ -1,5 +1,24 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.camel.component.servlet;
 
+import java.net.URL;
+import java.nio.file.Paths;
+import java.text.MessageFormat;
 import org.jboss.arquillian.container.test.api.Deployment;
 import org.jboss.arquillian.container.test.api.RunAsClient;
 import org.jboss.arquillian.junit.Arquillian;
@@ -10,13 +29,10 @@ import org.jboss.shrinkwrap.api.spec.WebArchive;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
-import java.net.URL;
-import java.nio.file.Paths;
-import java.text.MessageFormat;
-
 import static com.jayway.restassured.RestAssured.given;
 import static org.hamcrest.CoreMatchers.equalTo;
 
+
 /**
  * @author arnaud.deprez
  * @since 18/04/16
@@ -24,29 +40,29 @@ import static org.hamcrest.CoreMatchers.equalTo;
 @RunWith(Arquillian.class)
 public class ServletAsyncArquillianTest {
 
-	@Deployment
-	public static Archive<?> createTestArchive() {
-		// this is a WAR project so use WebArchive
-		return ShrinkWrap.create(WebArchive.class)
-			// add the web.xml
-			.setWebXML(Paths.get("src/test/resources/org/apache/camel/component/servlet/web-spring-async.xml").toFile());
-	}
+    @Deployment
+    public static Archive<?> createTestArchive() {
+        // this is a WAR project so use WebArchive
+        return ShrinkWrap.create(WebArchive.class)
+            // add the web.xml
+            .setWebXML(Paths.get("src/test/resources/org/apache/camel/component/servlet/web-spring-async.xml").toFile());
+    }
 
-	/**
-	 *
-	 * @param url the URL is the URL to the web application that was deployed
-	 * @throws Exception
-	 */
-	@Test
-	@RunAsClient
-	public void testHello(@ArquillianResource URL url) throws Exception {
-		final String name = "Arnaud";
-		given().
-			baseUri(url.toString()).
-			queryParam("name", name).
-		when().
-			get("/services/hello").
-		then().
-			body(equalTo(MessageFormat.format("Hello {0} how are you?", name)));
-	}
+    /**
+     *
+     * @param url the URL is the URL to the web application that was deployed
+     * @throws Exception
+     */
+    @Test
+    @RunAsClient
+    public void testHello(@ArquillianResource URL url) throws Exception {
+        final String name = "Arnaud";
+        given().
+            baseUri(url.toString()).
+            queryParam("name", name).
+        when().
+            get("/services/hello").
+        then().
+            body(equalTo(MessageFormat.format("Hello {0} how are you?", name)));
+    }
 }


Mime
View raw message