-
Bug
-
Resolution: Fixed
-
P3
-
8
-
b02
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8183834 | 8u161 | Ivan Gerasimov | P3 | Resolved | Fixed | b01 |
JDK-8192568 | emb-8u161 | Ivan Gerasimov | P3 | Resolved | Fixed | b01 |
FULL PRODUCT VERSION :
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [version 10.0.14393]
A DESCRIPTION OF THE PROBLEM :
Pattern.compile throws StringIndexOutOfBoundsException instead of PatternSyntaxException for the pattern string "[" with canonical equivalence (CANON_EQ) flag set.
See https://josm.openstreetmap.de/ticket/13870 for a real-life scenario where a pattern is validated during user input.
As per QUality outreach, please add "josm-found" label to this bug report.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the following code:
Pattern.compile("[", Pattern.CANON_EQ);
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
PatternSyntaxException
ACTUAL -
StringIndexOutOfBoundsException
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.StringIndexOutOfBoundsException: String index out of range: 1
at java.lang.String.codePointAt(String.java:687)
at java.util.regex.Pattern.normalizeCharClass(Pattern.java:1416)
at java.util.regex.Pattern.normalize(Pattern.java:1392)
at java.util.regex.Pattern.compile(Pattern.java:1659)
at java.util.regex.Pattern.<init>(Pattern.java:1351)
at java.util.regex.Pattern.compile(Pattern.java:1054)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.regex.Pattern;
public class PatternBug {
public static void main(String[] args) throws Exception {
Pattern.compile("[", Pattern.CANON_EQ);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
catch StringIndexOutOfBoundsException in caller's code
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [version 10.0.14393]
A DESCRIPTION OF THE PROBLEM :
Pattern.compile throws StringIndexOutOfBoundsException instead of PatternSyntaxException for the pattern string "[" with canonical equivalence (CANON_EQ) flag set.
See https://josm.openstreetmap.de/ticket/13870 for a real-life scenario where a pattern is validated during user input.
As per QUality outreach, please add "josm-found" label to this bug report.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the following code:
Pattern.compile("[", Pattern.CANON_EQ);
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
PatternSyntaxException
ACTUAL -
StringIndexOutOfBoundsException
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.StringIndexOutOfBoundsException: String index out of range: 1
at java.lang.String.codePointAt(String.java:687)
at java.util.regex.Pattern.normalizeCharClass(Pattern.java:1416)
at java.util.regex.Pattern.normalize(Pattern.java:1392)
at java.util.regex.Pattern.compile(Pattern.java:1659)
at java.util.regex.Pattern.<init>(Pattern.java:1351)
at java.util.regex.Pattern.compile(Pattern.java:1054)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.regex.Pattern;
public class PatternBug {
public static void main(String[] args) throws Exception {
Pattern.compile("[", Pattern.CANON_EQ);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
catch StringIndexOutOfBoundsException in caller's code
- backported by
-
JDK-8183834 StringIndexOutOfBoundsException in Pattern.compile with CANON_EQ flag
-
- Resolved
-
-
JDK-8192568 StringIndexOutOfBoundsException in Pattern.compile with CANON_EQ flag
-
- Resolved
-