Skip to content

Commit eaedde0

Browse files
authored
Merge pull request #77 from CodesAway/bugfix-0.9.1
Bugfix 0.9.1
2 parents e9bf074 + e7cbea2 commit eaedde0

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

BEXCodeCompare/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>info.codesaway</groupId>
66
<artifactId>bex</artifactId>
7-
<version>0.9.0</version>
7+
<version>0.9.1</version>
88
<name>BEX Code Compare</name>
99
<description>Be Enhanced Code Compare</description>
1010
<properties>

BEXCodeCompare/src/main/java/info/codesaway/bex/matching/BEXMatcher.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static info.codesaway.bex.matching.BEXGroupMatchSetting.DEFAULT;
44
import static info.codesaway.bex.matching.BEXGroupMatchSetting.STOP_WHEN_VALID;
5+
import static info.codesaway.bex.matching.BEXMatchingStateOption.MISMATCHED_BRACKETS;
56
import static info.codesaway.bex.matching.BEXMatchingUtilities.extractJavaTextStates;
67
import static info.codesaway.bex.matching.BEXMatchingUtilities.hasNextChar;
78
import static info.codesaway.bex.matching.BEXMatchingUtilities.hasText;
@@ -475,7 +476,7 @@ private BEXMatchingState search(final int start, final int end,
475476
if (bracketEndIndex != -1) {
476477
char bracketStart = bracketStarts.charAt(bracketEndIndex);
477478
if (lastChar(brackets) != bracketStart) {
478-
return new BEXMatchingState(i, brackets.toString());
479+
return new BEXMatchingState(i, brackets.toString(), MISMATCHED_BRACKETS);
479480
} else {
480481
// Remove last character
481482
brackets.setLength(brackets.length() - 1);

BEXCodeCompare/src/test/java/info/codesaway/bex/matching/BEXMatcherTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
import static info.codesaway.bex.util.BEXUtilities.entry;
77
import static org.assertj.core.api.Assertions.assertThat;
88
import static org.assertj.core.api.Assertions.assertThatThrownBy;
9+
import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively;
10+
11+
import java.time.Duration;
912

1013
import org.junit.jupiter.api.Test;
1114

@@ -385,4 +388,13 @@ void testDuplicateGroupNameInRegexDoesNotMatchGroupValue() {
385388
String text = "something Sunday Sat";
386389
testNoBEXMatch(pattern, text);
387390
}
391+
392+
@Test
393+
// Issue #75
394+
void testMismatchedBracketsDoesNotCauseInfiniteLoop() {
395+
String pattern = "if (:[before]blah:[after])";
396+
String text = "if (something) blah";
397+
398+
assertTimeoutPreemptively(Duration.ofSeconds(1), () -> testNoBEXMatch(pattern, text));
399+
}
388400
}

BEXCodeRefactoring/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,4 @@
162162
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
163163
</repository>
164164
</distributionManagement>
165-
</project>
165+
</project>

BEXCodeRefactoringExamples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,4 @@
156156
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
157157
</repository>
158158
</distributionManagement>
159-
</project>
159+
</project>

0 commit comments

Comments
 (0)