Skip to content

Conversation

nosan
Copy link
Contributor

@nosan nosan commented Aug 23, 2025

See #35369

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Aug 23, 2025
@nosan nosan force-pushed the 35369 branch 2 times, most recently from a722667 to a596879 Compare August 23, 2025 22:25
private static final Object NULL = new Object() {

@Override
public String toString() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that overriding this method is not necessary, what's the purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason that the method is overridden isn't for functionality but for debugging purposes.

Screenshot 2025-08-25 at 10 08 17

When overridden:
Screenshot 2025-08-25 at 10 07 57

Previously, SingletonSupplier stored "null" in singletonInstance when
the supplied instance was "null". On subsequent get() calls, this was
treated as "uninitialized" and triggered another attempt to obtain an instance.

This commit ensures that a "null" returned from the instanceSupplier or
defaultSupplier is handled correctly, so that subsequent calls to get()
return "null" consistently instead of repeatedly invoking the supplier.

Signed-off-by: Dmytro Nosan <[email protected]>
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 or decided on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants