Backoff KotlinBeanInfoFactory for enum types.

We now no longer contribute properties for enum types.

Closes #2990
This commit is contained in:
Mark Paluch
2023-11-29 10:51:16 +01:00
parent 801dac992e
commit 5ac30bf620
2 changed files with 13 additions and 2 deletions

View File

@@ -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<>();

View File

@@ -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
}
}