FELIX-2605 : FilterHandler should pre-compile regular expression
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@999261 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/http/base/src/main/java/org/apache/felix/http/base/internal/handler/FilterHandler.java b/http/base/src/main/java/org/apache/felix/http/base/internal/handler/FilterHandler.java
index fe3ca0e..400fe45 100644
--- a/http/base/src/main/java/org/apache/felix/http/base/internal/handler/FilterHandler.java
+++ b/http/base/src/main/java/org/apache/felix/http/base/internal/handler/FilterHandler.java
@@ -16,25 +16,28 @@
*/
package org.apache.felix.http.base.internal.handler;
+import java.io.IOException;
+import java.util.regex.Pattern;
+
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+
import org.apache.felix.http.base.internal.context.ExtServletContext;
-import java.io.IOException;
public final class FilterHandler
extends AbstractHandler implements Comparable<FilterHandler>
{
private final Filter filter;
- private final String pattern;
+ private final Pattern regex;
private final int ranking;
public FilterHandler(ExtServletContext context, Filter filter, String pattern, int ranking)
{
super(context);
this.filter = filter;
- this.pattern = pattern;
this.ranking = ranking;
+ this.regex = Pattern.compile(pattern);
}
public Filter getFilter()
@@ -62,7 +65,7 @@
uri = "/";
}
- return uri.matches(this.pattern);
+ return this.regex.matcher(uri).matches();
}
public void handle(HttpServletRequest req, HttpServletResponse res, FilterChain chain)