Skip to content

Conversation

@ori0o0p
Copy link
Contributor

@ori0o0p ori0o0p commented Apr 18, 2025

Description

This PR modifies the LettuceClassUtils, ReplicaUtils, ReflectionTestUtils class to enforce noninstantiability by changing its constructor to private, aligning with Java best practices for utility classes (Effective Java, Item 4). Additionally, Javadoc is added to clarify the class's purpose and prevent misuse. Similar utility classes were reviewed to ensure consistency.

Key changes:

  • Changed LettuceClassUtils, ReplicaUtils, ReflectionTestUtils constructor to private to prevent instantiation.
  • No functional changes; maintains backward compatibility.

Related Issue

Closes #3265

Checklist

Additional Notes

  • Testing: No functional changes were made, so existing tests remain valid. Added a test to verify that LettuceClassUtils cannot be instantiated.
  • Impact: This change is internal and does not affect the public API or user-facing behavior.
  • Build Fix: Ensured compliance with formatter-maven-plugin by running mvn formatter:format and mvn formatter:validate.

- Changed constructor to private to prevent instantiation
@ori0o0p ori0o0p changed the title Make Utils Class constructor private to enforce noninstantiability Make Utility Class constructor private to enforce noninstantiability Apr 18, 2025
@tishun tishun added this to the 7.0.0.RELEASE milestone May 7, 2025
@tishun
Copy link
Collaborator

tishun commented May 7, 2025

I don't disagree with the change, but I think we can only accept it for a major release.

If somebody already uses these classes by instantiating them (which I agree is wrong, but would still work) we would break their code. So we need to target something other than a minor/patch release.

@tishun tishun requested a review from Copilot May 7, 2025 11:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@tishun tishun merged commit b6e3d98 into redis:main Aug 8, 2025
7 checks passed
@ggivo ggivo added type: breaking Breaking change type: techdebt Things that can be improved or refactored labels Sep 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: breaking Breaking change type: techdebt Things that can be improved or refactored

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enforce Noninstantiability in Utility Class with Private Constructor

3 participants