Buggy code:
public class AntPathMatcher implements PathMatcher { private static final int CACHE_TURNOFF_THRESHOLD = 65536 ; private static final Pattern VARIABLE_PATTERN = Pattern . compile ( "\\{[^//]+?\\}" ) ; public static final String DEFAULT_PATH_SEPARATOR = "//" ; private String pathSeparator = AntPathMatcher . DEFAULT_PATH_SEPARATOR ; private boolean trimTokens = true ; private volatile Boolean cachePatterns ; final Map < String , AntPathMatcher . AntPathStringMatcher > stringMatcherCache = new ConcurrentHashMap < String , AntPathMatcher . AntPathStringMatcher > ( 256 ) ; public void setPathSeparator ( String pathSeparator ) { } public void setTrimTokens ( boolean trimTokens ) { } public void setCachePatterns ( boolean cachePatterns ) { } @ Override public boolean isPattern ( String path ) { } @ Override public boolean match ( String pattern , String path ) { } @ Override public boolean matchStart ( String pattern , String path ) { } protected boolean doMatch ( String pattern , String path , boolean fullMatch , Map < String , String > uriTemplateVariables ) { } private boolean matchStrings ( String pattern , String str , Map < String , String > uriTemplateVariables ) { } protected AntPathMatcher . AntPathStringMatcher getStringMatcher ( String pattern ) { AntPathMatcher . AntPathStringMatcher matcher = null ; Boolean cachePatterns = this . cachePatterns ; if ( ( cachePatterns == null ) || ( cachePatterns . booleanValue ( ) ) ) { matcher = this . stringMatcherCache . get ( pattern ) ; } if ( matcher == null ) { matcher = new AntPathMatcher . AntPathStringMatcher ( pattern ) ; <START_BUG> if ( ( cachePatterns == null ) && ( ( this . stringMatcherCache . size ( ) ) == ( AntPathMatcher . CACHE_TURNOFF_THRESHOLD ) ) ) { <END_BUG> this . cachePatterns = false ; this . stringMatcherCache . clear ( ) ; return matcher ; } if ( ( cachePatterns == null ) || ( cachePatterns . booleanValue ( ) ) ) { this . stringMatcherCache . put ( pattern , matcher ) ; } } return matcher ; } @ Override public String extractPathWithinPattern ( String pattern , String path ) { } @ Override public Map < String , String > extractUriTemplateVariables ( String pattern , String path ) { } @ Override public String combine ( String pattern1 , String pattern2 ) { } private String slashConcat ( String path1 , String path2 ) { } @ Override public Comparator < String > getPatternComparator ( String path ) { } protected static class AntPathStringMatcher { private static final Pattern GLOB_PATTERN = Pattern . compile ( "\\?|\\*|\\{((?:\\{[^//]+?\\}|[^//{}]|\\\\[{}])+?)\\}" ) ; private static final String DEFAULT_VARIABLE_PATTERN = "(.*)" ; private final Pattern pattern ; private final List < String > variableNames = new LinkedList < String > ( ) ; public AntPathStringMatcher ( String pattern ) { } private String quote ( String s , int start , int end ) { } public boolean matchStrings ( String str , Map < String , String > uriTemplateVariables ) { } } protected static class AntPatternComparator implements Comparator < String > { private final String path ; public AntPatternComparator ( String path ) { } @ Override public int compare ( String pattern1 , String pattern2 ) { } private boolean isNullOrCaptureAllPattern ( String pattern ) { } private int getWildCardCount ( String pattern ) { } private int getPatternLength ( String pattern ) { } } }

Fix:
if ( ( cachePatterns == null ) && ( ( this . stringMatcherCache . size ( ) ) >= ( AntPathMatcher . CACHE_TURNOFF_THRESHOLD ) ) ) {