if (!batch.isDone()) { expiredBatches.add(batch); } else {
/** * We can retry a send if the error is transient and the number of attempts taken is fewer than the maximum allowed. * We can also retry OutOfOrderSequence exceptions for future batches, since if the first batch has failed, the * future batches are certain to fail with an OutOfOrderSequence exception. */ private boolean canRetry(ProducerBatch batch, ProduceResponse.PartitionResponse response, long now) { return !batch.hasReachedDeliveryTimeout(accumulator.getDeliveryTimeoutMs(), now) && batch.attempts() < this.retries && !batch.isDone() && ((response.error.exception() instanceof RetriableException) || (transactionManager != null && transactionManager.canRetry(response, batch))); }
Errors error = response.error; if (error == Errors.MESSAGE_TOO_LARGE && batch.recordCount > 1 && !batch.isDone() && (batch.magic() >= RecordBatch.MAGIC_VALUE_V2 || batch.isCompressed())) {