diff --git a/config/src/test/java/org/springframework/security/SpringSecurityCoreVersionSerializableTests.java b/config/src/test/java/org/springframework/security/SpringSecurityCoreVersionSerializableTests.java index 557f4d879e..de2eb382d7 100644 --- a/config/src/test/java/org/springframework/security/SpringSecurityCoreVersionSerializableTests.java +++ b/config/src/test/java/org/springframework/security/SpringSecurityCoreVersionSerializableTests.java @@ -298,9 +298,13 @@ static Stream> getClassesToSerialize() throws Exception { for (BeanDefinition component : components) { Class clazz = Class.forName(component.getBeanClassName()); boolean isAbstract = Modifier.isAbstract(clazz.getModifiers()); + if (isAbstract) { + continue; + } boolean matchesExpectedSerialVersion = ObjectStreamClass.lookup(clazz) .getSerialVersionUID() == securitySerialVersionUid; - if (!isAbstract && matchesExpectedSerialVersion) { + boolean isUnderTest = generatorByClassName.containsKey(clazz); + if (matchesExpectedSerialVersion || isUnderTest) { classes.add(clazz); } }