spring-projects / spring-projects/spring-security

Consider replacing `.flatMap` with `.handle` where appropriate for performance reasons

Open
#6,525 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

in: core status: feedback-provided
Dominant language
Java
Stars
9.6k
Forks
6.3k
Avg merge
2d 11h
Merged PRs (30d)
52

Description

Hello.

https://github.com/spring-projects/spring-security/blob/0c2a7e03f780113867dd23c7c6f5f407bc854aed/core/src/main/java/org/springframework/security/authentication/ReactiveAuthenticationManagerAdapter.java#L44-L51

cases like this can be replaced with Reactor's .handle operator to improve the performance.

Something like:

.handle( (t, sink) -> {
	try {
		sink.next(authenticationManager.authenticate(t));
	} catch(Throwable error) {
		sink.error(error);
	}
})

Or even:

if (a.isAuthenticated()) {
	sink.next(a);
} else {
	sink.complete();
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with core/src/main/java/org/springframework/security/authentication/ReactiveAuthenticationManagerAdapter.java at the linked lines and inspect how the current flatMap flow handles authentication results and errors. Identify other appropriate cases, then ensure any replacements preserve the existing authenticated, unauthenticated, and error behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend, performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.