Skip to content

Fix AddOrUpdateAnnotation recipe changing implicit value into explicit value in annotations with arrays #5693

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

Conversation

jevanlingen
Copy link
Contributor

@jevanlingen jevanlingen commented Jul 1, 2025

What's changed?

When updating an existing annotation property, the recipe should not change implicit values.

What's your motivation?

The recipe creates uncompilable code when using an array with a implicit value.

For example:

@Foo({"oldTest"})
public class A {}

is turned into:

@Foo(value = "newTest1,newTest2", {"newTest1", "newTest2"})
public class A {}

where you would have expected:

@Foo({"newTest1", "newTest2"})
public class A {}

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@jevanlingen jevanlingen requested a review from JohannisK July 1, 2025 09:47
@jevanlingen jevanlingen self-assigned this Jul 1, 2025
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Jul 1, 2025
@jevanlingen jevanlingen added bug Something isn't working recipe Requested Recipe labels Jul 1, 2025
@jevanlingen jevanlingen force-pushed the AddOrUpdateAnnotationAttribute-change-implicit-into-explicit-value-for-arrays branch from 27b9c64 to 07a56ef Compare July 1, 2025 09:48
@jevanlingen jevanlingen marked this pull request as draft July 1, 2025 10:07
@jevanlingen jevanlingen marked this pull request as ready for review July 1, 2025 13:40
@jevanlingen jevanlingen moved this from In Progress to Ready to Review in OpenRewrite Jul 1, 2025
@jevanlingen jevanlingen merged commit 7a29c18 into main Jul 2, 2025
2 checks passed
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Jul 2, 2025
@jevanlingen jevanlingen deleted the AddOrUpdateAnnotationAttribute-change-implicit-into-explicit-value-for-arrays branch July 2, 2025 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working recipe Requested Recipe
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants