You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, would it be possible to replace CachedRegExPatternSupplier.map by a synchronized map? Or define custom supplier implements RegExPatternSupplier is recommended?
import java.util.WeakHashMap;
public class CachedRegExPatternSupplier implements RegExPatternSupplier {
private final RegExPatternSupplier wrapped;
private final WeakHashMap<String, RegExPattern> map = new WeakHashMap<>();
public CachedRegExPatternSupplier(RegExPatternSupplier wrapped) {
this.wrapped = wrapped;
}
@Override
public RegExPattern newPattern(String pattern) throws InvalidRegexException {
RegExPattern regExPattern1 = map.get(pattern);
if (regExPattern1 == null) {
regExPattern1 = wrapped.newPattern(pattern);
map.put(pattern, regExPattern1);
}
return regExPattern1;
}
}
Thanks!
The text was updated successfully, but these errors were encountered:
Hi, would it be possible to replace CachedRegExPatternSupplier.map by a synchronized map? Or define custom supplier implements RegExPatternSupplier is recommended?
Thanks!
The text was updated successfully, but these errors were encountered: