Skip to content

Conversation

@qkrtkdwns3410
Copy link

Summary

Improve CollectionUtils utility class with defensive programming practices.

Changes

1. Add private constructor

  • Prevent instantiation of utility class
  • Follow Java best practices for utility classes

2. Add null validation with Assert.notNull()

  • Enforce the contract documented in Javadoc (@param list must not be null)
  • Fail fast with clear error message instead of NullPointerException

3. Add unit tests for null validation

  • getFirstShouldRejectNullList()
  • getLastShouldRejectNullList()

Why these changes?

Before After
No instantiation prevention Private constructor
Silent NPE on null input Clear IllegalArgumentException
No test for null case Test coverage added

@qkrtkdwns3410 qkrtkdwns3410 marked this pull request as draft November 29, 2025 12:28
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 29, 2025
@qkrtkdwns3410 qkrtkdwns3410 force-pushed the refactor/collection-utils branch from 5bb0420 to 4908676 Compare November 29, 2025 12:30
@qkrtkdwns3410 qkrtkdwns3410 marked this pull request as ready for review November 29, 2025 12:30
Add private constructor to prevent instantiation of utility class. Add Assert.notNull validation to enforce method contract documented in Javadoc. Standardize assertion message capitalization for consistency.

Signed-off-by: 박상준 <[email protected]>
@qkrtkdwns3410 qkrtkdwns3410 force-pushed the refactor/collection-utils branch from 4908676 to c22662c Compare November 29, 2025 12:32
@mp911de mp911de added status: declined A suggestion or change that we don't feel we should currently apply has: ai-slop An bloated issue that contains low-value AI-generated content. and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 1, 2025
@mp911de
Copy link
Member

mp911de commented Dec 1, 2025

CollectionUtils is internal API, we don't need to add additional complexity and guards since this code is used internally only.

@mp911de mp911de closed this Dec 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

has: ai-slop An bloated issue that contains low-value AI-generated content. status: declined A suggestion or change that we don't feel we should currently apply

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants