Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Description of problem:
$ cat StrTest.java
public class StrTest {
public static void main (String[] args) {
String test = "abc\"def";
System.out.println("Test string is :" + test + ":");
test = test.replaceAll("\\", "");
System.out.println("Test string now :" + test + ":");
}
}
$ javac StrTest.java
$ java StrTest
Test string is :abc"def:
Exception in thread "main" java.util.regex.PatternSyntaxException: Unexpected internal error near index 1
\
^
at java.util.regex.Pattern.error(Pattern.java:1955)
at java.util.regex.Pattern.compile(Pattern.java:1702)
at java.util.regex.Pattern.<init>(Pattern.java:1351)
at java.util.regex.Pattern.compile(Pattern.java:1028)
at java.lang.String.replaceAll(String.java:2223)
at StrTest.main(StrTest.java:5)
zsh: exit 1 java StrTest
$ rpm -qf $(readlink -f $(which java))
java-1.8.0-openjdk-headless-1.8.0.71-2.b15.el7_2.x86_64
Yes, the pattern is wrong.
this is only java slash escape.
test = test.replaceAll("\\", "");
Regeex is second round of escaping. So to escape SINGLE slash, you need
test = test.replaceAll("\\\\", "");
However, slash is NOT in your original string of
String test = "abc\"def";
So I'm not sure what was yours goal.
Maybe;
public static void main (String[] args) {
String test = "abc\\\"def";
System.out.println("Test string is :" + test + ":");
test = test.replaceAll("\\\\", "");
System.out.println("Test string now :" + test + ":");
}
: Test string is :abc\"def:
: Test string now :abc"def:
So... this is not a bug. This is very correct behaviour.
Still it is PatternSyntaxException. And although I agree that " Unexpected internal error near index 1\^" is not exactly est message. It is correclty pointing to position in your regex(^\) and also in java code where it happened (at java.util.regex.Pattern.error(Pattern.java:1955)), So I would not claim it as bug. If you disagree, feel free to reopen.
I saw PatternSyntaxException earlier so when I see this "Unexpected internal error" I thought this is something different. I guess it would be better to have consistent error messages in every case possible but I'll leave it up to you to make the final call whether this is worth changing or not. Thanks.
Description of problem: $ cat StrTest.java public class StrTest { public static void main (String[] args) { String test = "abc\"def"; System.out.println("Test string is :" + test + ":"); test = test.replaceAll("\\", ""); System.out.println("Test string now :" + test + ":"); } } $ javac StrTest.java $ java StrTest Test string is :abc"def: Exception in thread "main" java.util.regex.PatternSyntaxException: Unexpected internal error near index 1 \ ^ at java.util.regex.Pattern.error(Pattern.java:1955) at java.util.regex.Pattern.compile(Pattern.java:1702) at java.util.regex.Pattern.<init>(Pattern.java:1351) at java.util.regex.Pattern.compile(Pattern.java:1028) at java.lang.String.replaceAll(String.java:2223) at StrTest.main(StrTest.java:5) zsh: exit 1 java StrTest $ rpm -qf $(readlink -f $(which java)) java-1.8.0-openjdk-headless-1.8.0.71-2.b15.el7_2.x86_64