Spring-boot: 2.0.0.RC2 fails to bind ConfigurationProperties of type List<Class<? extends Throwable>>

Created on 22 Feb 2018  路  6Comments  路  Source: spring-projects/spring-boot

Spring Boot 2.0.0.RC2 fails to bind a configuration property of type List<Class<? extends Throwable>>.
With 2.0.0.RC1 everything was working fine.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::            (v2.0.0.RC2)

01:11:06.495 [main] INFO  o.j.a.o.OmnifacesPropertiesIT - Starting OmnifacesPropertiesIT on Larss-Air.fritz.box with PID 27009 (started by larsgrefer in /Volumes/Daten/git/joinfaces/joinfaces-autoconfigure)
01:11:06.501 [main] INFO  o.j.a.o.OmnifacesPropertiesIT - The following profiles are active: propertyTest
01:18:34.409 [main] WARN  o.s.w.c.s.GenericWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'jsf.omnifaces-org.joinfaces.autoconfigure.omnifaces.OmnifacesProperties': Could not bind properties to 'OmnifacesProperties' : prefix=jsf.omnifaces, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'jsf.omnifaces.exception-types-to-unwrap' to java.util.List<java.lang.Class<java.lang.Throwable>>
01:18:34.777 [main] ERROR o.s.b.d.LoggingFailureAnalysisReporter - 

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to bind properties under 'jsf.omnifaces.exception-types-to-unwrap' to java.util.List<java.lang.Class<java.lang.Throwable>>:

    Reason: No converter found capable of converting from type [java.lang.String] to type [@org.joinfaces.autoconfigure.configuration.ServletContextInitParameter java.util.List<java.lang.Class<java.lang.Throwable>>]

Action:

Update your application's configuration

01:18:34.813 [main] ERROR o.s.test.context.TestContextManager - Caught exception while allowing TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener@75aea2ba] to prepare test instance [org.joinfaces.autoconfigure.omnifaces.OmnifacesPropertiesIT@2a47597]
java.lang.IllegalStateException: Failed to load ApplicationContext
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:125)
    at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:107)
    at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
    at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:242)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'jsf.omnifaces-org.joinfaces.autoconfigure.omnifaces.OmnifacesProperties': Could not bind properties to 'OmnifacesProperties' : prefix=jsf.omnifaces, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'jsf.omnifaces.exception-types-to-unwrap' to java.util.List<java.lang.Class<java.lang.Throwable>>
    at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.bind(ConfigurationPropertiesBindingPostProcessor.java:109)
    at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:93)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:423)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1702)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
    at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:138)
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117)
    ... 24 common frames omitted
Caused by: org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'jsf.omnifaces.exception-types-to-unwrap' to java.util.List<java.lang.Class<java.lang.Throwable>>
    at org.springframework.boot.context.properties.bind.Binder.handleBindError(Binder.java:250)
    at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:226)
    at org.springframework.boot.context.properties.bind.Binder.lambda$bindBean$4(Binder.java:331)
    at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:72)
    at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:61)
    at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:53)
    at org.springframework.boot.context.properties.bind.Binder.lambda$null$5(Binder.java:339)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1351)
    at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
    at org.springframework.boot.context.properties.bind.Binder.lambda$bindBean$6(Binder.java:340)
    at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:439)
    at org.springframework.boot.context.properties.bind.Binder$Context.withBean(Binder.java:425)
    at org.springframework.boot.context.properties.bind.Binder$Context.access$400(Binder.java:379)
    at org.springframework.boot.context.properties.bind.Binder.bindBean(Binder.java:337)
    at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:279)
    at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:221)
    at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:210)
    at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:192)
    at org.springframework.boot.context.properties.ConfigurationPropertiesBinder.bind(ConfigurationPropertiesBinder.java:78)
    at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.bind(ConfigurationPropertiesBindingPostProcessor.java:106)
    ... 42 common frames omitted
Caused by: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [@org.joinfaces.autoconfigure.configuration.ServletContextInitParameter java.util.List<java.lang.Class<java.lang.Throwable>>]
    at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:321)
    at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:194)
    at org.springframework.boot.context.properties.bind.BindConverter.convert(BindConverter.java:75)
    at org.springframework.boot.context.properties.bind.IndexedElementsBinder.convert(IndexedElementsBinder.java:143)
    at org.springframework.boot.context.properties.bind.IndexedElementsBinder.bindIndexed(IndexedElementsBinder.java:84)
    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:58)
    at org.springframework.boot.context.properties.bind.Binder.lambda$bindAggregate$2(Binder.java:306)
    at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:439)
    at org.springframework.boot.context.properties.bind.Binder$Context.access$100(Binder.java:379)
    at org.springframework.boot.context.properties.bind.Binder.bindAggregate(Binder.java:305)
    at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:263)
    at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:221)
    ... 67 common frames omitted

java.lang.IllegalStateException: Failed to load ApplicationContext

    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:125)
    at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:107)
    at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
    at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:242)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'jsf.omnifaces-org.joinfaces.autoconfigure.omnifaces.OmnifacesProperties': Could not bind properties to 'OmnifacesProperties' : prefix=jsf.omnifaces, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'jsf.omnifaces.exception-types-to-unwrap' to java.util.List<java.lang.Class<java.lang.Throwable>>
    at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.bind(ConfigurationPropertiesBindingPostProcessor.java:109)
    at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:93)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:423)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1702)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:388)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
    at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:138)
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117)
    ... 24 more
Caused by: org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'jsf.omnifaces.exception-types-to-unwrap' to java.util.List<java.lang.Class<java.lang.Throwable>>
    at org.springframework.boot.context.properties.bind.Binder.handleBindError(Binder.java:250)
    at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:226)
    at org.springframework.boot.context.properties.bind.Binder.lambda$bindBean$4(Binder.java:331)
    at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:72)
    at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:61)
    at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:53)
    at org.springframework.boot.context.properties.bind.Binder.lambda$null$5(Binder.java:339)
    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    at java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1351)
    at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
    at org.springframework.boot.context.properties.bind.Binder.lambda$bindBean$6(Binder.java:340)
    at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:439)
    at org.springframework.boot.context.properties.bind.Binder$Context.withBean(Binder.java:425)
    at org.springframework.boot.context.properties.bind.Binder$Context.access$400(Binder.java:379)
    at org.springframework.boot.context.properties.bind.Binder.bindBean(Binder.java:337)
    at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:279)
    at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:221)
    at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:210)
    at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:192)
    at org.springframework.boot.context.properties.ConfigurationPropertiesBinder.bind(ConfigurationPropertiesBinder.java:78)
    at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.bind(ConfigurationPropertiesBindingPostProcessor.java:106)
    ... 42 more
Caused by: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [@org.joinfaces.autoconfigure.configuration.ServletContextInitParameter java.util.List<java.lang.Class<java.lang.Throwable>>]
    at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:321)
    at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:194)
    at org.springframework.boot.context.properties.bind.BindConverter.convert(BindConverter.java:75)
    at org.springframework.boot.context.properties.bind.IndexedElementsBinder.convert(IndexedElementsBinder.java:143)
    at org.springframework.boot.context.properties.bind.IndexedElementsBinder.bindIndexed(IndexedElementsBinder.java:84)
    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:58)
    at org.springframework.boot.context.properties.bind.Binder.lambda$bindAggregate$2(Binder.java:306)
    at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:439)
    at org.springframework.boot.context.properties.bind.Binder$Context.access$100(Binder.java:379)
    at org.springframework.boot.context.properties.bind.Binder.bindAggregate(Binder.java:305)
    at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:263)
    at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:221)
    ... 67 more

Working Unit test: https://github.com/persapiens/joinfaces/blob/0e7c5a02a28b9c0785cf350150b5b0c1e96c9b11/joinfaces-autoconfigure/src/test/java/org/joinfaces/autoconfigure/omnifaces/OmnifacesPropertiesIT.java#L51

Broken Unit test https://github.com/persapiens/joinfaces/blob/72d592897fb41efcc9e128500e77c77a072a49fb/joinfaces-autoconfigure/src/test/java/org/joinfaces/autoconfigure/omnifaces/OmnifacesPropertiesIT.java#L51

regression

Most helpful comment

@larsgrefer Great news! Thanks for reporting this before we went GA.

All 6 comments

Here's a small addition to ConfigurationPropertiesTests that replicates it:

    @Test
    public void loadWhenBindingToListOfGenericClassShouldBind() {
        SimpleTypeConverter simpleTypeConverter = new SimpleTypeConverter();
        this.context.getBeanFactory().copyRegisteredEditorsTo(simpleTypeConverter);
        Class<?> converted = simpleTypeConverter
                .convertIfNecessary("java.lang.RuntimeException", Class.class);
        assertThat(converted).isEqualTo(RuntimeException.class);
        load(ListOfGenericClassProperties.class, "test.list=java.lang.RuntimeException");
        ListOfGenericClassProperties bean = this.context
                .getBean(ListOfGenericClassProperties.class);
        assertThat(bean.getList()).containsExactly(RuntimeException.class);
    }

OK, I think I know what's going on. In RC1 we had a PropertyEditorConverter class that would bridge the two type conversion worlds. In RC2 we dropped that in favor of calling SimpleTypeConverter directly first.

When we call SimpleTypeConverter we skip Collection conversion because we don't have information about the generics. That means we end up in the ConversionService, but it doesn't know how to convert String -> Class, so the element conversion fails.

The logic is:

  • Skip SimpleTypeConverter because it's a Collection
  • Ask ConversionService to convert String -> List<Class>.
  • Conversion service finds DelimitedStringToCollectionConverter
  • DelimitedStringToCollectionConverter asks ConversionService about element type
  • ConversionService doesn't know how to convert String -> Class

Conversion fails.

I think we'll need to make BindConverter aware of Collection, Map and Array types. Implementing some logic similar to TypeConverterDelegate.convertToTypedCollection which we can't directly use.

@larsgrefer You you try the latest SNAPSHOT if you get a chance to see if this is now fixed for you?

@philwebb Sure. The current 2.0.0.BUILD-SNAPSHOT works fine.

@larsgrefer Great news! Thanks for reporting this before we went GA.

Was this page helpful?
0 / 5 - 0 ratings