From c061168d4c5d19ec6f808f58304190a45fbd1e77 Mon Sep 17 00:00:00 2001 From: Jun Rao Date: Sun, 5 Oct 2014 19:43:04 -0700 Subject: [PATCH] avoid using await with timeout --- .../apache/kafka/clients/producer/internals/BufferPool.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/clients/src/main/java/org/apache/kafka/clients/producer/internals/BufferPool.java b/clients/src/main/java/org/apache/kafka/clients/producer/internals/BufferPool.java index 169a656..aa91e14 100644 --- a/clients/src/main/java/org/apache/kafka/clients/producer/internals/BufferPool.java +++ b/clients/src/main/java/org/apache/kafka/clients/producer/internals/BufferPool.java @@ -125,14 +125,11 @@ public final class BufferPool { // loop over and over until we have a buffer or have reserved // enough memory to allocate one while (accumulated < size) { - try { - long startWait = time.nanoseconds(); - moreMemory.await(300, TimeUnit.MILLISECONDS); - long endWait = time.nanoseconds(); - this.waitTime.record(endWait - startWait, time.milliseconds()); - } catch (InterruptedException e) { - // This should never happen. Just let it go. - } + long startWait = time.nanoseconds(); + moreMemory.await(); + long endWait = time.nanoseconds(); + this.waitTime.record(endWait - startWait, time.milliseconds()); + // check if we can satisfy this request from the free list, // otherwise allocate memory if (accumulated == 0 && size == this.poolableSize && !this.free.isEmpty()) { -- 1.8.5.2 (Apple Git-48)