Skip to content

Add RuntimeHints for FactorGrantedAuthority - #19593

Open
jyx-07 wants to merge 1 commit into
spring-projects:mainfrom
jyx-07:gh-18739
Open

Add RuntimeHints for FactorGrantedAuthority#19593
jyx-07 wants to merge 1 commit into
spring-projects:mainfrom
jyx-07:gh-18739

Conversation

@jyx-07

@jyx-07 jyx-07 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

FactorGrantedAuthority shipped without any RuntimeHints registration, so under a GraalVM native image it has no reflection or Java-serialization support. This breaks any caller that serializes it via plain Java serialization — for example Spring Session Data Redis's JdkSerializationRedisSerializer — which fails with:

com.oracle.svm.core.jdk.UnsupportedFeatureError: SerializationConstructorAccessor class not found for declaringClass: org.springframework.security.core.authority.FactorGrantedAuthority (targetConstructorClass: java.lang.Object)

FactorGrantedAuthority carries a java.time.Instant, whose own serialized form delegates to the JDK-internal java.time.Ser proxy class, so that type needs the same treatment (referenced via TypeReference.of("java.time.Ser") since it isn't public API).

This registers reflection and Java-serialization hints for FactorGrantedAuthority, Instant, and java.time.Ser in the existing CoreSecurityRuntimeHints, using TypeHint.Builder#withJavaSerialization, alongside the other Authentication-related types it already covers for the same class of problem.

Credit to @k6leung, who diagnosed the root cause and validated this exact set of hints as a workaround in #18739.

Test plan

  • Added RuntimeHintsPredicates-based tests to CoreSecurityRuntimeHintsTests asserting reflection and Java-serialization hints are registered for FactorGrantedAuthority, Instant, and java.time.Ser.
  • ./gradlew :spring-security-core:test — full module suite passes.

Closes gh-18739

FactorGrantedAuthority shipped without RuntimeHints registration,
so it was missing reflection and serialization support under a
GraalVM native image. This breaks callers that cache it via Java
serialization, such as Spring Session Data Redis's
JdkSerializationRedisSerializer, which fails with
"SerializationConstructorAccessor class not found" because the
constructor accessor for the class was never generated at build
time.

FactorGrantedAuthority carries a java.time.Instant, whose own
serialized form delegates to the JDK-internal java.time.Ser proxy,
so that type needs the same treatment.

Register FactorGrantedAuthority, Instant, and java.time.Ser in
CoreSecurityRuntimeHints using TypeHint.Builder#withJavaSerialization,
alongside the other Authentication-related types it already covers
for the same reason.

Closes spring-projectsgh-18739

Signed-off-by: jyx-07 <s25069@gsm.hs.kr>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FactorGrantedAuthority causes Spring Session Data Redis to throw SerializationException under Graalvm Native Image

2 participants