public static <T> T requiredSingleResult(@Nullable Collection<T> results) throws IncorrectResultSizeDataAccessException {
        if (CollectionUtils.isEmpty(results)) {
            throw new EmptyResultDataAccessException(1);
        } else if (results.size() > 1) {
            throw new IncorrectResultSizeDataAccessException(1, results.size());
        } else {
            return results.iterator().next();
        }
    }

    @Nullable
    public static <T> T nullableSingleResult(@Nullable Collection<T> results) throws IncorrectResultSizeDataAccessException {
        if (CollectionUtils.isEmpty(results)) {
            throw new EmptyResultDataAccessException(1);
        } else if (results.size() > 1) {
            throw new IncorrectResultSizeDataAccessException(1, results.size());
        } else {
            return results.iterator().next();
        }
    }

Comment From: snicoll

Thanks for the report but pasting our own code with no further comment does not really convey what you mean. I guess you're saying that nullableSingleResult does not seem to return null.

There is a note in the method that you've committed and yet seems to be key to your report:

// This is identical to the requiredSingleResult implementation but differs in the
// semantics of the incoming Collection (which we currently can't formally express)

I am going to close this as the report isn't actionable. If you meant something else, then please explain and we can reconsider.

Comment From: nkoo21

The implementation of nullableSingleResult and nullableSingleResult methods is the same NullableSingleResult should return null when the collection is empty 微信截图_20231229155717

Comment From: snicoll

@nkoo21 I don't know how you managed to take a screenshot that does not include the two lines of Javadoc that I've pasted above. If you're still confused about this method, see the history of #20773