feat(spring-security): instrument UsernameNotFoundException.fromUsername for Spring Security 7#11589
Draft
wconti27 wants to merge 1 commit into
Draft
feat(spring-security): instrument UsernameNotFoundException.fromUsername for Spring Security 7#11589wconti27 wants to merge 1 commit into
wconti27 wants to merge 1 commit into
Conversation
…ame for Spring Security 7 Spring Security 7 (shipped with Spring Boot 4) changes how UsernameNotFoundException is constructed in UserDetailsService implementations: InMemoryUserDetailsManager and similar now call the new static factory UsernameNotFoundException.fromUsername(String) rather than the public constructor. The existing constructor-based UsernameNotFoundExceptionInstrumentation no longer fires on that path. Adds UsernameNotFoundExceptionFactoryInstrumentation (alongside the existing sibling) that hooks fromUsername via @Advice.OnMethodEnter and calls SpringSecurityUserEventDecorator.DECORATE.onUserNotFound(username). Adds onUserNotFound(String) overload to SpringSecurityUserEventDecorator that forwards into the existing no-arg path (forward-compat with the SS7 factory signature). Bumps latestDepTestImplementation spring-boot-starter-* from 3.+ to 4.+ so CI exercises Spring Boot 4 / Spring Security 7. Adds UsernameNotFoundFromUsernameTest (JUnit 5 Java) that verifies: - instrumentedType() targets UsernameNotFoundException - decorator overload is callable without throwing (null and non-null) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
Contributor
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Spring Security 7 (included with Spring Boot 4) changes how
UsernameNotFoundExceptionis constructed:InMemoryUserDetailsManagerand similar implementations now use the new static factoryUsernameNotFoundException.fromUsername(String)rather than the public constructor. The existing constructor-basedUsernameNotFoundExceptionInstrumentationno longer fires on this path.UsernameNotFoundExceptionFactoryInstrumentationthat hooksfromUsername(String)via@Advice.OnMethodEnterand callsSpringSecurityUserEventDecorator.DECORATE.onUserNotFound(username)onUserNotFound(String)overload toSpringSecurityUserEventDecorator(forwards to existing no-arg path; forward-compat with SS7 factory signature)latestDepTestImplementationspring-boot-starter-* from3.+to4.+UsernameNotFoundFromUsernameTest(JUnit 5 Java)Test plan
./gradlew :dd-java-agent:instrumentation:spring:spring-security:spring-security-5.0:testpasses./gradlew :dd-java-agent:instrumentation:spring:spring-security:spring-security-6.0:testpasseslatestDepTestexercises Spring Boot 4 (Spring Security 7)UsernameNotFoundFromUsernameTestverifies decorator overload is callable without throwingPart of Spring Boot 4 support
This is one of several PRs adding Spring Boot 4 / Spring Security 7 support across the dd-trace-java instrumentation stack.
🤖 Generated with APM Instrumentation Toolkit