Skip to content

Commit

Permalink
Merge pull request #1553 from AzureAD/adjoh/make-patterns-constant
Browse files Browse the repository at this point in the history
Don't recompile patterns unneccesarily.
  • Loading branch information
AdamBJohnsonx authored Aug 18, 2020
2 parents e85b49c + 359b7df commit 5e7e61e
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ private static final class Challenge {
/**
* Regex sequence to parse schemes from WWW-Authenticate header values.
*/
private static final String REGEX_STRING_TOKEN_WITH_SCHEME = "^([^\\s|^=]+)[\\s|\\t]+([^=]*=[^=]*)+$";
private static final Pattern REGEX_STRING_TOKEN_WITH_SCHEME = Pattern.compile("^([^\\s|^=]+)[\\s|\\t]+([^=]*=[^=]*)+$");

/**
* Comma+space suffix used to preserve formatting during parsing.
Expand Down Expand Up @@ -601,8 +601,7 @@ private static boolean containsScheme(final String token) throws ResourceAuthent
}

Logger.i(TAG + methodName, "Testing token contains scheme", "input[" + token + "]");
final Pattern startWithScheme = Pattern.compile(REGEX_STRING_TOKEN_WITH_SCHEME);
final Matcher matcher = startWithScheme.matcher(token);
final Matcher matcher = REGEX_STRING_TOKEN_WITH_SCHEME.matcher(token);
final boolean match = matcher.matches();
Logger.i(TAG + methodName, "Testing String contains scheme", "Matches? [" + match + "]");
return match;
Expand Down

0 comments on commit 5e7e61e

Please sign in to comment.