DATACMNS-1278 - Make sure that SimpleTypeHolder always treats enums as simple.

We now explicitly check for an enum type in SimpleTypeHolder.isSimpleType(…) and resort to true immediately. Before that an enum implementing an interface could have seen a false for the actual enum type in case the interface type had been checked first and (correctly) produced a false. In the check for the actual enum type, depending on the iteration order through the cached values we could've hit the cached false for the interface or the cached true value for Enum.
This commit is contained in:
Oliver Gierke
2018-03-12 10:47:26 +01:00
parent 91c7d1b199
commit 0f174f6867
2 changed files with 14 additions and 1 deletions

View File

@@ -131,6 +131,15 @@ public class SimpleTypeHolderUnitTests {
assertThat(holder.isSimpleType(ExtendedPerson.class)).isFalse();
}
@Test // DATACMNS-1278
public void alwaysConsidersEnumsSimple() {
SimpleTypeHolder holder = SimpleTypeHolder.DEFAULT;
assertThat(holder.isSimpleType(SomeInterface.class)).isFalse();
assertThat(holder.isSimpleType(InterfacedEnum.class)).isTrue();
}
enum SimpleEnum {
FOO;
@@ -155,4 +164,8 @@ public class SimpleTypeHolderUnitTests {
static class ExtendedPerson extends Person {
}
interface SomeInterface {}
enum InterfacedEnum implements SomeInterface {}
}