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

@Validated in @ConfigurationProperties doesn't work when running in native image #6975

Closed
KimSeongIl opened this issue Jul 12, 2023 · 2 comments
Labels

Comments

@KimSeongIl
Copy link

Describe the issue

It worked fine on the jvm, but when I run it on the native image I get an error.
But if I remove the Pattern annotation, it works fine.

Why is this issue occurring?
How can I solve this problem?

Steps to reproduce the issue

  1. git clone https://github.com/KimSeongIl/demo.git
  2. nativeCompile
  3. nativeRun

DemoContext.kt

@ConfigurationProperties(prefix = "demo.context")
@Validated
class DemoContext {

    var exclude: List<Exclude> = mutableListOf()

    data class Exclude(
        var url: List<String>? = null,

        var httpMethod: List<HttpMethod>? = null,

        var httpStatus: List<@Pattern(regexp="^([1-5][x|X]{2}|[1-5][0-9]{2})\$") String>? = null,

        var elapsedTime: Long? = null
    )

}

application.yml

demo:
  context:
    exclude:
      - httpStatus: 2xx

nativeRun result

Binding to target [Bindable@517a5ddb type = java.util.List<DemoContext$Exclude>, value = 'provided', annotations = array<Annotation>[[empty]]] failed:

    Property: demo.context.exclude[0].httpstatus
    Value: "2xx"
    Origin: class path resource [application.yml] - 31:21
    Reason: The elements [demo.context.exclude[0].httpstatus] were left unbound.

Action:

Update your application's configuration

Describe GraalVM and your environment

spring boot version: 3.1.0
graalvm plugin version: id("org.graalvm.buildtools.native") version "0.9.20"
graalvm version: 22.3.r17

More details

spring-projects/spring-boot#37101

discussed in the above issue
@sdeleuze said it looks like a graalvm bug.

@sdeleuze
Copy link
Collaborator

@KimSeongIl Thanks for creating this issue. If you close it by mistake, could you please reopen it?

@sdeleuze
Copy link
Collaborator

I just saw spring-projects/spring-framework#6976, so I guess we are fine.

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

No branches or pull requests

2 participants