capistrant commented on code in PR #18743:
URL: https://github.com/apache/druid/pull/18743#discussion_r2528097467


##########
server/src/main/java/org/apache/druid/segment/realtime/appenderator/StreamAppenderator.java:
##########
@@ -653,7 +653,7 @@ public ListenableFuture<Object> persistAll(@Nullable final 
Committer committer)
       numPersistedRows += sink.getNumRowsInMemory();
       bytesPersisted += sink.getBytesInMemory();
 
-      final int limit = sink.isWritable() ? hydrants.size() - 1 : 
hydrants.size();
+      final int limit = sink.isWritable() ? Integer.max(0, hydrants.size() - 
1) : hydrants.size();

Review Comment:
   I couldn't figure out how to accomplish it. So for full disclosure the test 
case I came up with is courtesy of Claude coming up with a way to force the 
empty list of hydrants scenario. Confirmed that without the fix it is an IAE 
and with the change, no exception. 



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to