In the cloud-config/configclient sample from spring-native in the sb-3.0.x branch, I get this exception when running the native image:
org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.profiles.active' to java.util.Set<java.lang.String>
at org.springframework.boot.context.properties.bind.Binder.handleBindError(Binder.java:387)
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:347)
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:332)
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:262)
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:223)
at org.springframework.boot.context.config.Profiles.getProfiles(Profiles.java:101)
at org.springframework.boot.context.config.Profiles.getActivatedProfiles(Profiles.java:88)
at org.springframework.boot.context.config.Profiles.<init>(Profiles.java:82)
at org.springframework.boot.context.config.ConfigDataEnvironment.withProfiles(ConfigDataEnvironment.java:277)
at org.springframework.boot.context.config.ConfigDataEnvironment.processAndApply(ConfigDataEnvironment.java:233)
at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:96)
at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:89)
at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:109)
at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:94)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:85)
at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:66)
at java.util.ArrayList.forEach(ArrayList.java:1511)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:120)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:114)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:65)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:351)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:304)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1307)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1296)
at com.example.configclient.ConfigClientApplication.main(ConfigClientApplication.java:13)
Caused by: org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.util.ArrayList<?>] to type [java.util.LinkedHashSet<java.lang.String>] for value '[ci]'
at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:47)
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:192)
at org.springframework.boot.context.properties.bind.BindConverter.convert(BindConverter.java:109)
at org.springframework.boot.context.properties.bind.BindConverter.convert(BindConverter.java:100)
at org.springframework.boot.context.properties.bind.IndexedElementsBinder.convert(IndexedElementsBinder.java:142)
at org.springframework.boot.context.properties.bind.IndexedElementsBinder.bindValue(IndexedElementsBinder.java:97)
at org.springframework.boot.context.properties.bind.IndexedElementsBinder.bindIndexed(IndexedElementsBinder.java:83)
at org.springframework.boot.context.properties.bind.IndexedElementsBinder.bindIndexed(IndexedElementsBinder.java:70)
at org.springframework.boot.context.properties.bind.CollectionBinder.bindAggregate(CollectionBinder.java:49)
at org.springframework.boot.context.properties.bind.AggregateBinder.bind(AggregateBinder.java:56)
at org.springframework.boot.context.properties.bind.Binder.lambda$bindAggregate$3(Binder.java:438)
at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:590)
at org.springframework.boot.context.properties.bind.Binder.bindAggregate(Binder.java:438)
at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:399)
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:343)
... 27 common frames omitted
Caused by: java.lang.IllegalArgumentException: Could not instantiate Collection type: java.util.LinkedHashSet
at org.springframework.core.CollectionFactory.createCollection(CollectionFactory.java:210)
at org.springframework.core.convert.support.CollectionToCollectionConverter.convert(CollectionToCollectionConverter.java:81)
at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:41)
... 41 common frames omitted
Caused by: java.lang.NoSuchMethodException: java.util.LinkedHashSet.<init>()
at java.lang.Class.getConstructor0(DynamicHub.java:3585)
at java.lang.Class.getDeclaredConstructor(DynamicHub.java:2754)
at org.springframework.util.ReflectionUtils.accessibleConstructor(ReflectionUtils.java:185)
at org.springframework.core.CollectionFactory.createCollection(CollectionFactory.java:206)
... 43 common frames omitted
It looks like there are some hints missing for the properties binding support.
Comment From: wilkinsona
I wonder if Framework should have hints for well-known collection types that CollectionFactory may try to instantiate? WDYT, @sdeleuze?
Comment From: sdeleuze
That's an interesting one, I have always wondered why we had specific issues with LinkedHashSet and not with a lot of other use cases. I think that's potentially because CollectionFactory#createCollection uses the non reflective constructors only for interface types, not when using the specific implementation class like LinkedHashSet here.
Maybe we could just use the non reflective variant when passing well-known implementations, that would avoid creating reflective hints for this kind of use case.
If you think that's a reasonable proposal, please create a related Spring Framework issue I will take care of it (after validation with Juergen it is ok).
Comment From: wilkinsona
Maybe we could just use the non reflective variant when passing well-known implementations, that would avoid creating reflective hints for this kind of use case
I like that idea. It'll bring a small benefit to everyone by avoiding reflection. I'll open an issue so we can see what Juergen thinks.
Comment From: sdeleuze
Based on my tests, this issue is now fixed via spring-projects/spring-framework#28718 available as of Spring Framework 6.0.0-M5 so this issue can probably be closed.
Comment From: mhalbritter
Nice, thanks for letting us know.