Overview
Types like ResultSetExtractor<T>
where the return type nullness depends on the generic type nullness should have their declaration improved to be more flexible as defined in JSpecify generic type documentation.
So the current declaration and similar patterns
@FunctionalInterface
public interface ResultSetExtractor<T> {
@Nullable T extractData(ResultSet rs) throws SQLException, DataAccessException;
}
Should be updated to
@FunctionalInterface
public interface ResultSetExtractor<T extends @Nullable Object> {
T extractData(ResultSet rs) throws SQLException, DataAccessException;
}
Unless I am mistaken, since ResultSetExtractor<T>
is syntaxic sugar for ResultSetExtractor<T extends Object>
, declaring ResultSetExtractor<T extends @Nullable Object>
should not break the compatibility for users not using checkers like NullAway. If they do and they are using nullable type, the breakage is on purpose and will allow them to specify ResultSetExtractor<@Nullable T>
on usage side.
Related Issues
-
34911
-
35147