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

JSP parse errors logged to console during mod build #4240

Open
bryceatmoderne opened this issue Jun 8, 2024 · 0 comments
Open

JSP parse errors logged to console during mod build #4240

bryceatmoderne opened this issue Jun 8, 2024 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers parser-xml

Comments

@bryceatmoderne
Copy link
Contributor

bryceatmoderne commented Jun 8, 2024

What version of OpenRewrite are you using?

I am using

  • OpenRewrite v8.27.2
  • Maven plugin v3.
  • rewrite-module v8.27.2

How are you running OpenRewrite?

https://github.com/2345free/video-web has several JSP files that the CLI fails to parse. Any parse errors encountered are logged to the CLI console, as opposed to build.log like so:

../mods/latest/mod build 2345free/video-web
        ▛▀▀▚▖  ▗▄▟▜
        ▌   ▜▄▟▀  ▐
        ▛▀▀█▀▛▀▀▀▀▜
        ▌▟▀  ▛▀▀▀▀▜
        ▀▀▀▀▀▀▀▀▀▀▀
Moderne CLI 3.4.0-SNAPSHOT

> Selecting repositories

> 2345free/video-web@master
Selected 1 repositories (0.05s)

> Building LST(s)

> 2345free/video-web@master
    Build output will be written to /Users/brycetompkins/repos/mass-ingest-300K/2345free/video-web/.moderne/build/20240528090619-nDiqh/build.log
    > Step 1 - build with Maven
        Selected the 1.8.0_412-zulu JDK
    > Step 2 - build resources using the native CLI
 26% |===> ---------| (36s) ...345free/video-web/src/main/webapp/WEB-INF/jsp/about.jspline 63:14 token recognition error at: '-'
line 63:15 token recognition error at: '-'
line 63:21 token recognition error at: '<'
line 83:6 token recognition error at: '-'
line 83:7 token recognition error at: '-'
line 83:8 token recognition error at: '<'
line 85:6 token recognition error at: '-'
line 85:7 token recognition error at: '-'
line 85:8 token recognition error at: '<'
line 86:6 token recognition error at: '-'
line 86:7 token recognition error at: '-'
line 86:8 token recognition error at: '<'
line 87:6 token recognition error at: '-'
line 87:7 token recognition error at: '-'
line 87:8 token recognition error at: '<'
line 88:6 token recognition error at: '-'
line 88:7 token recognition error at: '-'
line 88:8 token recognition error at: '<'
 46% |======> ------| (36s) ...ree/video-web/src/main/webapp/WEB-INF/jsp/configure.jspline 157:47 token recognition error at: '"<'
line 159:46 token recognition error at: '"<'
line 168:6 token recognition error at: '-'
line 168:7 token recognition error at: '-'
line 168:12 token recognition error at: '<'
 66% |========> ----| (36s) ...K/2345free/video-web/src/main/webapp/WEB-INF/jsp/in.jspline 8:23 token recognition error at: '('
line 8:27 token recognition error at: ')'
line 8:28 token recognition error at: ';'
 80% |==========> --| (36s) .../video-web/src/main/webapp/WEB-INF/jsp/videocontent.jspline 150:10 token recognition error at: '-'
line 150:11 token recognition error at: '-'
line 150:20 token recognition error at: '<'
 86% |===========> -| (36s) ...ree/video-web/src/main/webapp/WEB-INF/jsp/videoedit.jspline 36:33 token recognition error at: ''<'
line 36:57 token recognition error at: '('
line 36:66 token recognition error at: ')'
line 58:28 token recognition error at: '<'
line 98:51 token recognition error at: '"<'
line 100:50 token recognition error at: '"<'
line 127:10 token recognition error at: '-'
line 127:11 token recognition error at: '-'
line 127:20 token recognition error at: '<'
        ! 9 sources produced parse errors
    ✓ Built LST /Users/brycetompkins/repos/mass-ingest-300K/2345free/video-web/.moderne/build/20240528090619-nDiqh/video-web-20240528090656-ast.jar
    + Reported build metrics to Moderne
    + Cleaned 0 older builds.
Built 1 repositories. (36s)

* What to do next
    > Run mod run 2345free/video-web --recipe FindParseFailures to analyze the parse errors
    > Run mod run 2345free/video-web --recipe=<RecipeName>

It should also be verified that a correct parser is being used to parse .jsp files.

It appears this message is originating from the openrewrite's ANTLR XML parser when it fails to parse a JSP-specific comment, such as

<%-- commented out --%>

https://github.com/openrewrite/rewrite/blob/main/rewrite-xml/src/main/java/org/openrewrite/xml/XmlParser.java

Looking at XmlParser#parseInputs, this particular error should be suppressed with the following code:

parser.removeErrorListeners();
parser.addErrorListener(new ForwardingErrorListener(input.getPath(), ctx));

But that's not the current behaviour.

What is the smallest, simplest way to reproduce the problem?

See above

What did you expect to see?

No errors when parsing JSP files

What did you see instead?

Errors such as

line 127:20 token recognition error at: '<'

What is the full stack trace of any errors you encountered?

N/A

Are you interested in [contributing a fix to OpenRewrite]

N/A

@bryceatmoderne bryceatmoderne added the bug Something isn't working label Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers parser-xml
Projects
Status: Backlog
Development

No branches or pull requests

2 participants