]> source.dussan.org Git - vaadin-framework.git/commitdiff
simplified isStaticResourceRequest and improved its performance (#11758)
authorFabian Lange <lange.fabian@gmail.com>
Wed, 12 Jun 2013 14:48:00 +0000 (16:48 +0200)
committerFabian Lange <lange.fabian@gmail.com>
Tue, 9 Jul 2013 11:08:42 +0000 (13:08 +0200)
The previous implementation did first check if the PathInfo was empty (null returned).
This is almost never the case in reality. But if it happens, then the RequestURI would never contain contextRoot+"/VAADIN/".
Next it checked that contextUri was not null, and checked if the Uri started with "/VAADIN/".
This only would have worked in case the context root would have been "".
The next case checked was if the Uri starts with contextRoot+"/VAADIN/".
This is what you normally want to check. The only valid other case from before (contextRoot == "") is also covered by this line.

What you would have seen in normal deployments is:
* First if exit only for first request (http://demo.vaadin.com/sampler/) (and sometimes not even that depending on trailing slash config)
* Second exit only on no context root deployments (getContextRoot() returns "")
* Last exit in all other cases

Additionally, the existing implementation does not work correctly for the case getContextRoot would return null (which thankfully no container does).

Change-Id: I500e0c5eb0ac2bfa0b32af91800b2f7f303485ff

server/src/com/vaadin/server/VaadinServlet.java

index 43bcb3d3947dfe667bf17ebce680828e1fd86ff7..6f45ee493057fc5798064f4e1add38f40cacb229 100644 (file)
@@ -1006,20 +1006,8 @@ public class VaadinServlet extends HttpServlet implements Constants {
     }
 
     protected boolean isStaticResourceRequest(HttpServletRequest request) {
-        String pathInfo = request.getPathInfo();
-        if (pathInfo == null) {
-            return false;
-        }
-
-        if ((request.getContextPath() != null)
-                && (request.getRequestURI().startsWith("/VAADIN/"))) {
-            return true;
-        } else if (request.getRequestURI().startsWith(
-                request.getContextPath() + "/VAADIN/")) {
-            return true;
-        }
-
-        return false;
+        return request.getRequestURI().startsWith(
+                request.getContextPath() + "/VAADIN/");
     }
 
     /**