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

Prevent StackOverflowError in JavaTemplateJavaExtension #4443

Merged
merged 2 commits into from
Aug 25, 2024
Merged

Conversation

knutwannheden
Copy link
Contributor

The use of JavaTypeVisitor in JavaTemplateJavaExtension is what caused the StackOverflowError, as the JavaType graphs can contain cycles and don't provide any mechanism to guard against that.

While I understand the reason for using a JavaTypeVisitor to also correct the references to that type in the graph, it won't fix all references in any case, so it seems a bit futile. Until OpenRewrite provides a mechanism to "globally" update a type attribution, I feel like the best option here is to do what other recipes typically do: Just update the reference at hand.

The other alternative here would be to use the internal method unsafeSet().

The use of `JavaTypeVisitor` in `JavaTemplateJavaExtension` is what caused the `StackOverflowError`, as the `JavaType` graphs can contain cycles and don't provide any mechanism to guard against that.

While I understand the reason for using a `JavaTypeVisitor` to also correct the references to that type in the graph, it won't fix all references in any case, so it seems a bit futile. Until OpenRewrite provides a mechanism to "globally" update a type attribution, I feel like the best option here is to do what other recipes typically do: Just update the reference at hand.

The other alternative here would be to use the internal method `unsafeSet()`.

- Fixes: #4161
@knutwannheden knutwannheden merged commit 348e118 into main Aug 25, 2024
2 checks passed
@knutwannheden knutwannheden deleted the fix/4161 branch August 25, 2024 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

StackOverflowError on @java.lang.annotation.Documented due to self reference
2 participants