Skip to content

Commit dce9828

Browse files
committed
Update OOM handling outside of timeout
1 parent 2813d6b commit dce9828

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,7 @@ protected Node curNode() {
900900
* @param now The current time in milliseconds.
901901
* @param throwable The failure exception.
902902
*/
903+
@SuppressWarnings("NPathComplexity")
903904
final void fail(long now, Throwable throwable) {
904905
if (curNode != null) {
905906
runnable.nodeReadyDeadlines.remove(curNode);
@@ -921,6 +922,11 @@ final void fail(long now, Throwable throwable) {
921922
}
922923
nextAllowedTryMs = now + retryBackoff.backoff(tries++);
923924

925+
// Don't mask OutOfMemoryError as TimeoutException - propagate it directly
926+
if (throwable instanceof OutOfMemoryError) {
927+
handleFailure(throwable);
928+
return;
929+
}
924930
// If the call has timed out, fail.
925931
if (calcTimeoutMsRemainingAsInt(now, deadlineMs) <= 0) {
926932
handleTimeoutFailure(now, throwable);
@@ -956,10 +962,7 @@ private void handleTimeoutFailure(long now, Throwable cause) {
956962
log.debug("{} timed out at {} after {} attempt(s)", this, now, tries,
957963
new Exception(prettyPrintException(cause)));
958964
}
959-
// Don't mask OutOfMemoryError as TimeoutException - propagate it directly
960-
if (cause instanceof OutOfMemoryError) {
961-
handleFailure(cause);
962-
} else if (cause instanceof TimeoutException) {
965+
if (cause instanceof TimeoutException) {
963966
handleFailure(cause);
964967
} else {
965968
handleFailure(new TimeoutException(this + " timed out at " + now

0 commit comments

Comments
 (0)