10000JI opened a new pull request, #8121:
URL: https://github.com/apache/gravitino/pull/8121
## What changes were proposed in this pull request?
Add null safety checks in CatalogCreateRequest constructor to prevent
NullPointerException when type is null and provider is "hadoop". Additionally,
add a comprehensive test case to verify the fix works correctly and throws
IllegalArgumentException instead of NPE.
## Why are the changes needed?
- The constructor was vulnerable to NPE when
`this.provider.equalsIgnoreCase("hadoop")` was called with a null provider
- When type is null and provider is "hadoop",
`CatalogProvider.shortNameForManagedCatalog(type)` would throw NPE
- As mentioned by @justinmclean, relying on validate() call order is brittle
and a simple defensive check costs nothing while hardening the code
- Addresses the issue raised in #8082 where validate() was not being called
Fix: #8085
## Does this PR introduce any user-facing change?
No, this is purely a defensive programming improvement. The behavior for
valid inputs remains unchanged, and invalid inputs now throw clear
IllegalArgumentException with descriptive messages instead of cryptic NPE.
## How was this patch tested?
- Existing unit tests continue to pass, ensuring no functional regression
- Added a new test case `testCatalogCreateRequestNullTypeHadoopProvider()`
to verify NPE scenario throws IllegalArgumentException instead
- Local testing completed successfully with Gradle build and Spotless
formatting
- All common module tests pass
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]