Add final modifier and private constructor for JsonReader#14344
Conversation
|
Is your PR work in progress? Because I see changes only for 1 class |
| public final class JsonReader { | ||
|
|
||
| private JsonReader() { | ||
| throw new UnsupportedOperationException("Utility class"); |
There was a problem hiding this comment.
| throw new UnsupportedOperationException("Utility class"); | |
| throw new UnsupportedOperationException("Cannot instantiate a utility class"); |
There was a problem hiding this comment.
Can you apply this change to other PRs as well?
There was a problem hiding this comment.
Hi @InAnYan
Thank you for the review and suggestion! I'll update the error message in all the PRs.
It was discussed on gitter. I did see that it are only four lines which changed; and therefore asked for different PRs for each class. --> See answer to https://matrix.to/#/!FrLnwBcqmXcZxTMyJj:gitter.im/$U5RLcIJU695KPAp9A1MKmnSkpyjUYyrL0QiRIIz6hgI?via=gitter.im&via=matrix.org&via=tchncs.de The contributor could have asked, but he took 4 weeks to think and create all PRs at once. |
|
Hi @koppor, Apologies for the delay in responding! I did create all 6 separate PRs as discussed on Gitter, all linked to issue #14346. I should have communicated this more clearly upfront - sorry for any confusion. All PRs have been updated with the improved exception message as suggested by @InAnYan. Thank you for your patience and guidance! |
* Add final modifier and private constructor * Update exception message
Closes #14346
Added
finalmodifier and private constructor toJsonReaderutility class to prevent instantiation and subclassing, following Java best practices for utility classes containing only static methods.@espertusnu - This addresses the utility class refactoring discussed on Gitter.
Steps to test
./gradlew build./gradlew testMandatory checks
CHANGELOG.mdin a way that is understandable for the average user (if change is visible to the user)