justinmclean opened a new issue, #10605:
URL: https://github.com/apache/gravitino/issues/10605
### What would you like to be improved?
Dropping partition statistics can fail with a secondary NullPointerException
in the exception handler, which masks the original error. In
StatisticOperations, the catch block calls request.getDrops().stream() to build
the partitions string. If the incoming request is null, or getDrops() is null,
the handler throws another exception instead of returning the intended error
response.
This makes debugging harder and can turn a client/input validation failure
into an unexpected internal server error.
### How should we improve?
Make the exception handler null-safe before reading request.getDrops(). For
example, guard request and request.getDrops() and fall back to an empty string
or placeholder like "unknown" when the drop list is unavailable.
Here's a unit test to help:
```
@Test
public void testDropPartitionStatisticsWithNullDrops() {
when(tableDispatcher.tableExists(any())).thenReturn(true);
MetadataObject tableObject =
MetadataObjects.parse(
String.format("%s.%s.%s", catalog, schema, table),
MetadataObject.Type.TABLE);
Response response =
target(
"/metalakes/"
+ metalake
+ "/objects/"
+ tableObject.type()
+ "/"
+ tableObject.fullName()
+ "/statistics/partitions")
.request(MediaType.APPLICATION_JSON_TYPE)
.accept("application/vnd.gravitino.v1+json")
.post(entity("{\"drops\":null}",
MediaType.APPLICATION_JSON_TYPE));
Assertions.assertEquals(Response.Status.BAD_REQUEST.getStatusCode(),
response.getStatus());
Assertions.assertEquals(MediaType.APPLICATION_JSON_TYPE,
response.getMediaType());
ErrorResponse errorResponse = response.readEntity(ErrorResponse.class);
Assertions.assertEquals(ErrorConstants.ILLEGAL_ARGUMENTS_CODE,
errorResponse.getCode());
Assertions.assertEquals(
IllegalArgumentException.class.getSimpleName(),
errorResponse.getType());
}
```
--
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]