Repository: apache/kafka
File: clients/src/main/java/org/apache/kafka/clients/producer/internals/TransactionalRequestResult.java (Java)

Code before:
public final class TransactionalRequestResult {
    private final CountDownLatch latch;
    private volatile RuntimeException error = null;
    private final String operation;
    private volatile boolean isAcked = false;

    public TransactionalRequestResult(String operation) {
        this(new CountDownLatch(1), operation);
    }

    private TransactionalRequestResult(CountDownLatch latch, String operation) {
        this.latch = latch;
        this.operation = operation;
    }

    public void fail(RuntimeException error) {
        this.error = error;
        this.latch.countDown();
    }

    public void done() {
        this.latch.countDown();
    }

    public void await() {
        this.await(Long.MAX_VALUE, TimeUnit.MILLISECONDS, () -> new KafkaException("Unknown reason."));
    }

    public void await(long timeout, TimeUnit unit) {
        this.await(timeout, unit, () -> new KafkaException("Unknown reason."));
    }

    public void await(long timeout, TimeUnit unit, Supplier<KafkaException> potentialCauseException) {
        try {
            boolean success = latch.await(timeout, unit);
            if (!success) {
                throw new TimeoutException("Timeout expired after " + unit.toMillis(timeout) +
                    "ms while awaiting " + operation, potentialCauseException.get());
            }

            isAcked = true;
            if (error != null) {
                throw error;
            }
        } catch (InterruptedException e) {
            throw new InterruptException("Received interrupt while awaiting " + operation, e);
        }
    }

    public RuntimeException error() {
        return error;

Review comment (suggestion):
```suggestion
        this.await(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
```

Code after:
    private volatile RuntimeException error = null;
    private final String operation;
    private volatile boolean isAcked = false;

    public TransactionalRequestResult(String operation) {
        this(new CountDownLatch(1), operation);
    }

    private TransactionalRequestResult(CountDownLatch latch, String operation) {
        this.latch = latch;
        this.operation = operation;
    }

    public void fail(RuntimeException error) {
        this.error = error;
        this.latch.countDown();
    }

    public void done() {
        this.latch.countDown();
    }

    public void await(long timeout, TimeUnit unit, String expectedTimeoutReason) {
        try {
            boolean success = latch.await(timeout, unit);
            if (!success) {
                throw new TimeoutException("Timeout expired after " + unit.toMillis(timeout) +
                    "ms while awaiting " + operation + ". " + expectedTimeoutReason);
            }

            isAcked = true;
            if (error != null) {
                throw error;
            }
        } catch (InterruptedException e) {
            throw new InterruptException("Received interrupt while awaiting " + operation, e);
        }
    }

    public RuntimeException error() {
        return error;
    }

    public boolean isSuccessful() {
        return isCompleted() && error == null;
    }

    public boolean isCompleted() {
        return latch.getCount() == 0L;
    }