-
Bug
-
Resolution: Fixed
-
P4
-
6
-
b119
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.6.0_11"
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
See steps to reproduce and run the code snippet. The thread will hang in an infinite loop.
The regular expression pattern is invalid as far as I know; I don't think the "?+" is correct. I would think that Pattern.compile() should be throwing an exception.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run this simple 2-line code snippet (full class below).
Pattern pattern = Pattern.compile("(([0-9A-Z]+)([_]?+)*)*");
pattern.matcher("FOOOOO_BAAAR_FOOOOOOOOO_BA_ ").matches();
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should not hang.
ACTUAL -
VM hangs in an infinite loop.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.regex.Pattern;
public class RegexTest {
public static void main(String[] args) {
Pattern pattern = Pattern.compile("(([0-9A-Z]+)([_]?+)*)*");
pattern.matcher("FOOOOO_BAAAR_FOOOOOOOOO_BA_ ").matches();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Correct the regex.
java version "1.6.0_11"
Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
See steps to reproduce and run the code snippet. The thread will hang in an infinite loop.
The regular expression pattern is invalid as far as I know; I don't think the "?+" is correct. I would think that Pattern.compile() should be throwing an exception.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run this simple 2-line code snippet (full class below).
Pattern pattern = Pattern.compile("(([0-9A-Z]+)([_]?+)*)*");
pattern.matcher("FOOOOO_BAAAR_FOOOOOOOOO_BA_ ").matches();
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should not hang.
ACTUAL -
VM hangs in an infinite loop.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.regex.Pattern;
public class RegexTest {
public static void main(String[] args) {
Pattern pattern = Pattern.compile("(([0-9A-Z]+)([_]?+)*)*");
pattern.matcher("FOOOOO_BAAAR_FOOOOOOOOO_BA_ ").matches();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Correct the regex.
- relates to
-
JDK-6988218 RegEx matcher loops
-
- Resolved
-
-
JDK-7111813 Matcher.matches() enters in an infinite loop
-
- Closed
-