Fix StackOverflowError in BindingReflectionHintsRegistrar

This commit fixes the cycle detection in
BindingReflectionHintsRegistrar.

See gh-28683
This commit is contained in:
Sébastien Deleuze
2022-06-23 15:21:38 +02:00
parent a4ccec18f6
commit 61e9aa9f42
2 changed files with 74 additions and 42 deletions

View File

@@ -131,6 +131,15 @@ public class BindingReflectionHintsRegistrarTests {
});
}
@Test
void registerTypeForSerializationWithCycles() {
bindingRegistrar.registerReflectionHints(this.hints.reflection(), SampleClassWithCycles.class);
assertThat(this.hints.reflection().typeHints()).satisfiesExactlyInAnyOrder(
typeHint -> assertThat(typeHint.getType()).isEqualTo(TypeReference.of(SampleClassWithCycles.class)),
typeHint -> assertThat(typeHint.getType()).isEqualTo(TypeReference.of(List.class)));
}
static class SampleEmptyClass {
}
@@ -172,4 +181,15 @@ public class BindingReflectionHintsRegistrarTests {
}
}
static class SampleClassWithCycles {
public SampleClassWithCycles getSampleClassWithCycles() {
return null;
}
public List<SampleClassWithCycles> getSampleClassWithCyclesList() {
return null;
}
}
}