Applying the servlet fixes from r840 (on the snapshot) to trunk.
git-svn-id: https://google-guice.googlecode.com/svn/trunk@944 d779f126-a31b-0410-b53b-1d3aecad763e
diff --git a/servlet/src/com/google/inject/servlet/ManagedFilterPipeline.java b/servlet/src/com/google/inject/servlet/ManagedFilterPipeline.java
index 144f3cf..b382584 100755
--- a/servlet/src/com/google/inject/servlet/ManagedFilterPipeline.java
+++ b/servlet/src/com/google/inject/servlet/ManagedFilterPipeline.java
@@ -141,6 +141,13 @@
HttpServletRequest request = (HttpServletRequest) servletRequest;
+ // don't wrap the request if there are no servlets mapped. This prevents us from inserting our
+ // wrapper unless it's actually going to be used. This is necessary for compatibility for apps
+ // that downcast their HttpServletRequests to a concrete implementation.
+ if (!servletPipeline.hasServletsMapped()) {
+ return servletRequest;
+ }
+
//noinspection OverlyComplexAnonymousInnerClass
return new HttpServletRequestWrapper(request) {
diff --git a/servlet/src/com/google/inject/servlet/ManagedServletPipeline.java b/servlet/src/com/google/inject/servlet/ManagedServletPipeline.java
index 023a2f5..00faf7c 100755
--- a/servlet/src/com/google/inject/servlet/ManagedServletPipeline.java
+++ b/servlet/src/com/google/inject/servlet/ManagedServletPipeline.java
@@ -53,6 +53,10 @@
this.servletDefinitions = Collections.unmodifiableList(collectServletDefinitions(injector));
}
+ boolean hasServletsMapped() {
+ return !servletDefinitions.isEmpty();
+ }
+
/**
* Introspects the injector and collects all instances of bound {@code List<ServletDefinition>}
* into a master list.