Skip to content

Consistently declare nullability @Contract for core utilities #34934

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sbrannen opened this issue May 22, 2025 · 3 comments
Closed

Consistently declare nullability @Contract for core utilities #34934

sbrannen opened this issue May 22, 2025 · 3 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@sbrannen
Copy link
Member

sbrannen commented May 22, 2025

Overview

Although we have @Contract declarations for various methods in some of our core utilities (such as Assert and StringUtils), we have not yet consistently declared nullability contracts via @Contract for all applicable utility methods.

To provide better nullability support, we should therefore consistently declare method-level nullability contracts for the following core utilities.

  • SupplierUtils
  • ClassUtils
  • CollectionUtils
  • FileSystemUtils
  • ObjectUtils
  • PatternMatchUtils
  • ReflectionUtils
  • ResourceUtils
  • SerializationUtils
  • StringUtils
  • TypeUtils

Related Issues

@sbrannen sbrannen added this to the 7.0.0-M6 milestone May 22, 2025
@sbrannen sbrannen self-assigned this May 22, 2025
@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement labels May 22, 2025
@christophstrobl
Copy link
Member

When adding @Contract annotations please also consider switching CollectionUtils.contains(@Nullable Iterator<?> iterator, Object element) to CollectionUtils.contains(@Nullable Iterator<?> iterator, @Nullable Object element).

@sbrannen
Copy link
Member Author

Sure, we'll take that into consideration, @christophstrobl.

@sbrannen
Copy link
Member Author

When adding @Contract annotations please also consider switching CollectionUtils.contains(@Nullable Iterator<?> iterator, Object element) to CollectionUtils.contains(@Nullable Iterator<?> iterator, @Nullable Object element).

@christophstrobl, this will be addressed separately in:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants