Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Performance improvement for JSESSIONID handling

  • Loading branch information...
commit 550549400fa3f1a7a963cfb3bf7696c5181b3993 1 parent ae97e85
@chkal chkal authored
Showing with 6 additions and 3 deletions.
  1. +6 −3 core/src/main/java/com/ocpsoft/pretty/PrettyContext.java
View
9 core/src/main/java/com/ocpsoft/pretty/PrettyContext.java
@@ -17,6 +17,8 @@
import java.io.IOException;
import java.io.Serializable;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import javax.faces.context.FacesContext;
import javax.servlet.ServletRequest;
@@ -46,8 +48,8 @@
public static final String PRETTY_PREFIX = "pretty:";
private static final String CONTEXT_REQUEST_KEY = "prettyContext";
+ private static final Pattern JSESSIONID_PATTERN = Pattern.compile("(?i)^(.*);jsessionid=[\\w\\.]+(.*)");
private static final String JSESSIONID_REPLACEMENT = "$1$2";
- private static final String JSESSIONID_REGEX = "(?i)^(.*);jsessionid=[\\w\\.]+(.*)";
private PrettyConfig config;
@@ -84,9 +86,10 @@ protected PrettyContext(final HttpServletRequest request)
public static URL getRequestURL(final HttpServletRequest request)
{
String url = stripContextPath(request.getContextPath(), request.getRequestURI());
- if (url.matches(JSESSIONID_REGEX))
+ Matcher sessionIdMatcher = JSESSIONID_PATTERN.matcher(url);
+ if (sessionIdMatcher.matches())
{
- url = url.replaceFirst(JSESSIONID_REGEX, JSESSIONID_REPLACEMENT);
+ url = sessionIdMatcher.replaceFirst(JSESSIONID_REPLACEMENT);
}
String encoding = request.getCharacterEncoding() == null ? DEFAULT_ENCODING : request.getCharacterEncoding();
Please sign in to comment.
Something went wrong with that request. Please try again.