]> source.dussan.org Git - vaadin-framework.git/commitdiff
Avoid using the same Matcher from multiple threads (#10184) 08/408/1
authorLeif Åstrand <leif@vaadin.com>
Wed, 28 Nov 2012 08:58:43 +0000 (10:58 +0200)
committerLeif Åstrand <leif@vaadin.com>
Wed, 28 Nov 2012 08:58:55 +0000 (10:58 +0200)
Change-Id: I801a60db3a1b040db98fc597a35434c4a0b2ba83

server/src/com/vaadin/server/GlobalResourceHandler.java

index 13dbd006a44cf382dee473009f7c8930341814eb..acaa6a168e15a3f4a8125b2cab7bf61c1fe2d468 100644 (file)
@@ -60,9 +60,9 @@ public class GlobalResourceHandler implements RequestHandler {
     private int nextLegacyId = 0;
 
     // APP/global/[uiid]/[type]/[id]
-    private static final Matcher matcher = Pattern.compile(
-            "^/?" + ApplicationConstants.APP_PATH + '/' + RESOURCE_REQUEST_PATH
-                    + "(\\d+)/(([^/]+)(/.*))").matcher("");
+    private static final Pattern pattern = Pattern.compile("^/?"
+            + ApplicationConstants.APP_PATH + '/' + RESOURCE_REQUEST_PATH
+            + "(\\d+)/(([^/]+)(/.*))");
 
     @Override
     public boolean handleRequest(VaadinSession session, VaadinRequest request,
@@ -72,7 +72,7 @@ public class GlobalResourceHandler implements RequestHandler {
             return false;
         }
 
-        matcher.reset(pathInfo);
+        Matcher matcher = pattern.matcher(pathInfo);
         if (!matcher.matches()) {
             return false;
         }
@@ -81,9 +81,6 @@ public class GlobalResourceHandler implements RequestHandler {
         String type = matcher.group(3);
         String key = matcher.group(2);
 
-        // Allow GCing pathInfo string
-        matcher.reset();
-
         if (key == null) {
             return error(request, response, pathInfo
                     + " is not a valid global resource path");