Skip to content

Conversation

@Jenson3210
Copy link
Contributor

Add debug information and error handling for intermittent ParseError in GradleUseJunitJupiter

Summary

This PR addresses the intermittent ClassCastException: Cannot cast org.openrewrite.tree.ParseError to org.openrewrite.groovy.tree.G$CompilationUnit that occurs in Spring Boot 3.5 projects. The changes add comprehensive error handling and debugging capabilities to help identify the root cause of parsing failures.

Problem Context

The issue manifests as an intermittent ClassCastException when the code attempts to cast a ParseError to G.CompilationUnit at line 252. This occurs rarely but consistently across different projects.

Solution Approach

Rather than silently filtering out ParseErrors, this implementation:

  1. Provides fallback parsing: Uses GroovyParser when GradleParser fails, ensuring files are still processed
  2. Preserves diagnostic information: Attaches original parse errors as markers for debugging when this issue happens
  3. Enables comprehensive error analysis: When both parsers fail, provides detailed error information from both attempts

Testing

The changes maintain existing functionality while providing better error handling. Files that previously caused crashes will now either:

  • Be successfully processed using the GroovyParser fallback, or
  • Fail with detailed diagnostic information instead of generic ClassCastException

This approach ensures recipes continue working while gathering the debugging information needed to identify and fix the root cause of the intermittent parsing failures.

! This is not a fix proposal, but a information retrieval proposal, after which the clean solution still needs to be added !

@Jenson3210 Jenson3210 self-assigned this Sep 16, 2025
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Sep 16, 2025
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions could not be made:

  • src/main/java/org/openrewrite/java/testing/junit5/GradleUseJunitJupiter.java
    • lines 34-35

@github-project-automation github-project-automation bot moved this from In Progress to Ready to Review in OpenRewrite Sep 18, 2025
@Jenson3210 Jenson3210 marked this pull request as draft September 18, 2025 09:34
@Jenson3210
Copy link
Contributor Author

@knutwannheden You mentioned you had other idea to test this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready to Review

Development

Successfully merging this pull request may close these issues.

2 participants