justinmclean opened a new issue, #10127:
URL: https://github.com/apache/gravitino/issues/10127
### What would you like to be improved?
In POConverters.java POConverters.fromModelVersionPO(...) currently assumes
modelVersionPOs is non-empty and reads modelVersionPOs.get(0). When the list is
empty, it throws an IndexOutOfBoundsException from the collection internals.
### How should we improve?
Add explicit input validation at the start of the method and fail fast with
a clear exception (IllegalArgumentException).
Here's a unit test to help:
```
@Test
public void testFromModelVersionPOWithEmptyModelVersionPOs() {
NameIdentifier modelIdent = NameIdentifierUtil.ofModel("m", "c", "s",
"model1");
assertThrows(
IllegalArgumentException.class,
() ->
POConverters.fromModelVersionPO(
modelIdent, Collections.emptyList(), Collections.emptyList()));
}
```
add to
core/src/test/java/org/apache/gravitino/storage/relational/utils/TestPOConverters.java
--
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]