Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error executing command ReviewCode: java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near index #150

Closed
hbrands opened this issue Jul 1, 2021 · 5 comments · Fixed by #152
Assignees
Labels
Milestone

Comments

@hbrands
Copy link

hbrands commented Jul 1, 2021

Environment:
Windows 10
Spring Tool Suite
Version: 4.11.0.RELEASE
Build Id: 202106180608
(based on Eclipse 2021-06)

PMD Plug-in 4.24.0.v20210529-0600

I noticed a lot of errors in the PMD logfile:

2021/07/01 10:45:22.814 [Worker-173: ReviewCode] ERROR n.s.p.e.r.cmd.JobCommandProcessor - Error executing command ReviewCode: java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near index 50
D:\workspace\sts490\edrewemaster\example-demo\src\main\java\**\*.java\.*
                                                  ^
java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near index 50
D:\workspace\sts490\edrewemaster\example-demo\src\main\java\**\*.java\.*
                                                  ^
	at java.base/java.util.regex.Pattern.error(Pattern.java:2028)
	at java.base/java.util.regex.Pattern.escape(Pattern.java:2619)
	at java.base/java.util.regex.Pattern.atom(Pattern.java:2286)
	at java.base/java.util.regex.Pattern.sequence(Pattern.java:2210)
	at java.base/java.util.regex.Pattern.expr(Pattern.java:2069)
	at java.base/java.util.regex.Pattern.compile(Pattern.java:1783)
	at java.base/java.util.regex.Pattern.<init>(Pattern.java:1430)
	at java.base/java.util.regex.Pattern.compile(Pattern.java:1069)
	at net.sourceforge.pmd.eclipse.ui.actions.internal.InternalRuleSetUtil.convertStringPatterns(InternalRuleSetUtil.java:86)
	at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.filteredRuleSets(ReviewCodeCmd.java:675)
	at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.rulesetsFrom(ReviewCodeCmd.java:509)
	at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.determineFileExtensions(ReviewCodeCmd.java:304)
	at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.determineTotalWork(ReviewCodeCmd.java:274)
	at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.execute(ReviewCodeCmd.java:181)
	at net.sourceforge.pmd.eclipse.runtime.cmd.JobCommandProcessor$1.run(JobCommandProcessor.java:60)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

The index 50 is around "\m" of \main in this example.
I will attach a sample project which demonstrates this problem.
Hopefully you can reproduce the issue.
example-demo.zip

@hbrands
Copy link
Author

hbrands commented Jul 1, 2021

Maybe it's related to a change of commit
32840c9

@adangel adangel added this to the 4.26.0 milestone Jul 5, 2021
@adangel adangel self-assigned this Jul 5, 2021
@adangel adangel added the bug label Jul 9, 2021
@hbrands
Copy link
Author

hbrands commented Aug 5, 2021

@adangel After updating to version 4.26.0 I still observe similiar exceptions in the log file. This time it complains about the project root dir:

2021/08/05 14:27:09.070 [Worker-3: ReviewCode] ERROR n.s.p.e.r.cmd.JobCommandProcessor - Error executing command ReviewCode: java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near index 13
D:\workspace\gitlab\edrewemaster\edrewe-common\src\main\java\.*\*\.java
             ^
java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near index 13
D:\workspace\gitlab\edrewemaster\edrewe-common\src\main\java\.*\*\.java
             ^
	at java.base/java.util.regex.Pattern.error(Pattern.java:2028)
	at java.base/java.util.regex.Pattern.escape(Pattern.java:2619)
	at java.base/java.util.regex.Pattern.atom(Pattern.java:2286)
	at java.base/java.util.regex.Pattern.sequence(Pattern.java:2210)
	at java.base/java.util.regex.Pattern.expr(Pattern.java:2069)
	at java.base/java.util.regex.Pattern.compile(Pattern.java:1783)
	at java.base/java.util.regex.Pattern.<init>(Pattern.java:1430)
	at java.base/java.util.regex.Pattern.compile(Pattern.java:1069)
	at net.sourceforge.pmd.eclipse.ui.actions.internal.InternalRuleSetUtil.convertStringPatterns(InternalRuleSetUtil.java:88)
	at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.filteredRuleSets(ReviewCodeCmd.java:674)
	at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.rulesetsFrom(ReviewCodeCmd.java:510)
	at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.determineFileExtensions(ReviewCodeCmd.java:305)
	at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.determineTotalWork(ReviewCodeCmd.java:275)
	at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.execute(ReviewCodeCmd.java:181)
	at net.sourceforge.pmd.eclipse.runtime.cmd.JobCommandProcessor$1.run(JobCommandProcessor.java:60)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

This is with my real projects. I couldn't reproduce this with a test project yet. When I have more insights I'll let you know.

@hbrands
Copy link
Author

hbrands commented Aug 6, 2021

@adangel UPDATE: I think you can reproduce the remaining issue with my provided example project above if you extract it on Windows in a dir like "D:\workspace\gitlab" and import it as an existing project into an Eclipse workspace. It seems to me that the backsplash in the root path is not escaped for the regex, so "\g" is not recognized by Pattern#compile (whereas "\w" and "\e" is interpreted by Pattern#compile). Hope this helps.

@hbrands
Copy link
Author

hbrands commented Aug 10, 2021

@adangel Unfortunately I can't reopen the issue. Should I create a new issue?
Please give a short feedback, so that I know you have noticed my comments and I know what I should do.

@adangel
Copy link
Member

adangel commented Aug 14, 2021

@hbrands Please create a new issue, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants