-
Notifications
You must be signed in to change notification settings - Fork 349
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
Do not log ClassCastException
in MavenParser in case of malformed POM
#3701
Do not log ClassCastException
in MavenParser in case of malformed POM
#3701
Conversation
(cherry picked from commit b8545e1)
Thanks a lot for this improvement! I've gone ahead and updated your test to use the parser directly, as that's more convenient when asserting ParseErrors. Before your code change we returned a different ParseError from the In the new situation we still return a rewrite/rewrite-xml/src/main/java/org/openrewrite/xml/XmlParser.java Lines 60 to 62 in 8158227
|
ClassCastException
in MavenParser in case of malformed POM
Thank you for review and merge. I have couple of questions. So now the exception from the XML parsers itself should be logged and could be seen by the end user? Because this was a major PITA ;-) to understand and find out where this came from and which POM should be corrected and where. It the shame that we have a ParserError with a diff with the exact description where this went wrong. But it was obscured by the ClassCastException. Because I can't test it right now - are you sure that this is this way now? Another question: you mentioned and closed another issue with this PR; are you sure that there we have the same cause from the same place in code? The final question is like in my another ticket. The cause of all of this was that the parser parsed the original XML, but after the comparing the result with original XML some differences were found. Which causes a ParseError. And the question is: could we also change the behavior of this parser to behave more like the Maven one? So such errors wouldn't appear? |
Hi @api-from-the-ion ; You were right, the fix was incomplete; it's now been fixed in openrewrite/rewrite-maven-plugin@f6ffdc3 such that you should, finally, be able to see the original parser errors when problems occur. Thanks again!
That'll depend on what errors occur, and I hope my changes will help surface and resolve those errors. We have our own parser based on our XmlParser, which differs from the implementation Apache Maven uses. Without knowing the details of the errors you had been getting I can't say for certain which is better. I hope the above change help surface your issues, and please keep reporting any problems that you find; really helpful to have detailed feedback. |
What's changed?
Wrote the unit test for the case #3699 and proposed fix
What's your motivation?
Fixes #3699
Anything in particular you'd like reviewers to focus on?
No
Anyone you would like to review specifically?
No
Have you considered any alternatives or workarounds?
I don't think there are any, but I'm glad to hear about them.
Any additional context
After this fix, there is no ClassCastException. But the test asserts fails anyway because the POM is changed here - see the results of the tests. And now I don't know what to do with this. Should we suppress it or ignore it in the code itself? So that test would expect such changes or ignore them? Or is here some other way? Correct the parser, so these changes wouldn't appear and there would be no difference?
Checklist
./gradlew licenseFormat