Skip to content

added ConfigurationPropertiesDefaultValueTest for LST contains invalid nodes #713

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

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

tubbynl
Copy link

@tubbynl tubbynl commented May 22, 2025

What's changed?

  • a extra test as example for invalid code

What's your motivation?

i recently started using the @DefaultValue annotation to add sensible defaults on config properties in combination with java records. This works (as-in, compiles, tests, and runs as expected). Only when i run OpenRewrite it fails seemingly on parsing the code.

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.bind.DefaultValue;

@ConfigurationProperties("nl.tubby")
record TestTubbyProperties(
         @DefaultValue("https://www.tubby.nl") String url
) {
}

running ConfigurationPropertiesDefaultValueTest fails with the following error


LST contains erroneous nodes

  StringurlltValue("https://www.tubby.nl") String url

java.lang.IllegalStateException: LST contains erroneous nodes

  StringurlltValue("https://www.tubby.nl") String url

Anything in particular you'd like reviewers to focus on?

the parsing seems to "rewrite" the code invalidly

Have you considered any alternatives or workarounds?

  • adding the file to exclusions doesnt seem to work
  • remove the DefaultValue value attribute yields the same
  • removing the DefaultValue annotation alltogether works

Any additional context

  • rewrite-maven-plugin 6.9.0
  • rewrite-spring 6.7.0

active recipes

  • org.openrewrite.java.migrate.UpgradeToJava21
  • org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_3
  • org.openrewrite.java.testing.junit5.JUnit5BestPractices
  • org.openrewrite.java.spring.boot3.SpringBoot33BestPractices

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

@timtebeek timtebeek marked this pull request as draft May 28, 2025 17:59
@timtebeek
Copy link
Member

Hoi thanks! Indeed we've been having some problems so far parsing annotated constructor arguments for records; The problem is upstream, but we can keep this test here to validate the upstream fix (and once verified likely close this PR).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@tubbynl
Copy link
Author

tubbynl commented Jun 11, 2025

Tnx @timtebeek!

as i read it's interesting change in the parsing of records :) i'll wait till a testable version is released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

4 participants