Backoff KotlinBeanInfoFactory for enum types.
We now no longer contribute properties for enum types. Closes #2990
This commit is contained in:
@@ -48,7 +48,7 @@ public class KotlinBeanInfoFactory implements BeanInfoFactory, Ordered {
|
||||
@Override
|
||||
public BeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionException {
|
||||
|
||||
if (beanClass.isInterface()) {
|
||||
if (beanClass.isInterface() || beanClass.isEnum()) {
|
||||
return null; // back-off to leave interface-based properties to the default mechanism.
|
||||
}
|
||||
|
||||
@@ -56,7 +56,6 @@ public class KotlinBeanInfoFactory implements BeanInfoFactory, Ordered {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
KClass<?> kotlinClass = JvmClassMappingKt.getKotlinClass(beanClass);
|
||||
List<PropertyDescriptor> pds = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -73,6 +73,14 @@ class KotlinBeanInfoFactoryUnitTests {
|
||||
assertThat(pds).hasSize(1).extracting("name").containsOnly("firstname")
|
||||
}
|
||||
|
||||
@Test // GH-2990
|
||||
internal fun backsOffForEnums() {
|
||||
|
||||
val pds = BeanUtils.getPropertyDescriptors(MyEnum::class.java)
|
||||
|
||||
assertThat(pds).extracting("name").contains("ordinal")
|
||||
}
|
||||
|
||||
data class SimpleDataClass(val id: String, var name: String)
|
||||
|
||||
@JvmInline
|
||||
@@ -86,4 +94,8 @@ class KotlinBeanInfoFactoryUnitTests {
|
||||
fun getFirstname(): String
|
||||
}
|
||||
|
||||
enum class MyEnum {
|
||||
Foo, Bar
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user