Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import org.jspecify.annotations.Nullable;

import org.springframework.lang.Contract;

/**
* Service interface for encoding passwords.
*
Expand All @@ -36,6 +38,7 @@ public interface PasswordEncoder {
* @return A non-null encoded password, unless the rawPassword was null in which case
* the result must be null.
*/
@Contract("null -> null; !null -> !null")

Choose a reason for hiding this comment

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

LGTM! Technically, I think this contract should also be copied down to any implementations of encode in classes implementing PasswordEncoder as well. That way, if you enable NullAway's contract checking, it will check that the implementation adheres to the contract. Plus, right now if you write BCryptPasswordEncoder b = ...; x = b.encode(...);, NullAway won't see the contract on the interface method and won't apply it.

Copy link
Contributor Author

@scordio scordio Jan 13, 2026

Choose a reason for hiding this comment

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

Ah, good point! Addressed in #18490.

@Nullable String encode(@Nullable CharSequence rawPassword);

/**
Expand Down
Loading