mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[ignored]: fix thread safety by replacing Matcher.reset to new instance
* fix StringIndexOutOfBoundsException from (CPP-8843);
* remember compiled Pattern instead of Matcher;
* problem was introduced in c1180cfb7f
This commit is contained in:
@@ -34,13 +34,13 @@ import com.intellij.util.PathUtilRt;
|
||||
import com.intellij.util.PatternUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class IgnoredFileBean {
|
||||
private final String myPath;
|
||||
private final String myFilenameIfFile;
|
||||
private final String myMask;
|
||||
private final Matcher myMatcher;
|
||||
@Nullable private final Pattern myPattern;
|
||||
private final IgnoreSettingsType myType;
|
||||
private final Project myProject;
|
||||
private volatile VirtualFile myCachedResolved;
|
||||
@@ -51,7 +51,7 @@ public class IgnoredFileBean {
|
||||
myFilenameIfFile = IgnoreSettingsType.FILE.equals(type) ? PathUtilRt.getFileName(path) : null;
|
||||
myProject = project;
|
||||
myMask = null;
|
||||
myMatcher = null;
|
||||
myPattern = null;
|
||||
}
|
||||
|
||||
Project getProject() {
|
||||
@@ -61,12 +61,7 @@ public class IgnoredFileBean {
|
||||
IgnoredFileBean(String mask) {
|
||||
myType = IgnoreSettingsType.MASK;
|
||||
myMask = mask;
|
||||
if (mask == null) {
|
||||
myMatcher = null;
|
||||
}
|
||||
else {
|
||||
myMatcher = PatternUtil.fromMask(mask).matcher("");
|
||||
}
|
||||
myPattern = mask != null ? PatternUtil.fromMask(mask) : null;
|
||||
myPath = null;
|
||||
myFilenameIfFile = null;
|
||||
myProject = null;
|
||||
@@ -110,8 +105,7 @@ public class IgnoredFileBean {
|
||||
|
||||
public boolean matchesFile(VirtualFile file) {
|
||||
if (myType == IgnoreSettingsType.MASK) {
|
||||
myMatcher.reset(file.getName());
|
||||
return myMatcher.matches();
|
||||
return myPattern != null && myPattern.matcher(file.getName()).matches();
|
||||
}
|
||||
else {
|
||||
// quick check for 'file' == exact match pattern
|
||||
|
||||
Reference in New Issue
Block a user