Fix IgnoreRule#isMatch returning wrong result due to missing reset

The matcher has to be reset before using it, as was already done in the
other cases.

Bug: 423039
Change-Id: I87abaa7ad7f0aac8651db6e88d41427cacb4d776
Also-by: Ondrej Vrabec <ovrabec@netbeans.org>
Signed-off-by: Robin Stocker <robin@nibor.org>
This commit is contained in:
Robin Stocker 2013-12-03 22:25:40 +01:00
parent 7dc8a4f089
commit f4dae204a6
2 changed files with 13 additions and 0 deletions

View File

@ -340,6 +340,18 @@ public void testGetters() {
assertEquals(r.getPattern(), "/patter?");
}
@Test
public void testResetState() {
String pattern = "/build/*";
String target = "/build";
// Don't use the assert methods of this class, as we want to test
// whether the state in IgnoreRule is reset properly
IgnoreRule r = new IgnoreRule(pattern);
// Result should be the same for the same inputs
assertFalse(r.isMatch(target, true));
assertFalse(r.isMatch(target, true));
}
/**
* Check for a match. If target ends with "/", match will assume that the
* target is meant to be a directory.

View File

@ -198,6 +198,7 @@ public boolean isMatch(String target, boolean isDirectory) {
}
} else {
matcher.reset();
matcher.append(target);
if (matcher.isMatch())
return true;