From 4994afb73cf99dfcd537755997fc021cb1443ea6 Mon Sep 17 00:00:00 2001 From: Ashan Rathnaweera Date: Fri, 25 Oct 2024 10:25:24 +0530 Subject: [PATCH] Restructure the polling comparison logic --- .../databridge/core/internal/queue/EventBlockingQueue.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/data-bridge/org.wso2.carbon.databridge.core/src/main/java/org/wso2/carbon/databridge/core/internal/queue/EventBlockingQueue.java b/components/data-bridge/org.wso2.carbon.databridge.core/src/main/java/org/wso2/carbon/databridge/core/internal/queue/EventBlockingQueue.java index 63c9151c45..0bc874ff49 100644 --- a/components/data-bridge/org.wso2.carbon.databridge.core/src/main/java/org/wso2/carbon/databridge/core/internal/queue/EventBlockingQueue.java +++ b/components/data-bridge/org.wso2.carbon.databridge.core/src/main/java/org/wso2/carbon/databridge/core/internal/queue/EventBlockingQueue.java @@ -81,9 +81,9 @@ public synchronized void put(EventComposite eventComposite) { public EventComposite poll() { EventComposite eventComposite = super.poll(); currentSize.addAndGet(-eventComposite.getSize()); - if (semaphore.availablePermits() == 0 && ((currentEventCompositeSize + currentSize.get()) < maxSize) || isEmpty()) { + if (semaphore.availablePermits() == 0 && (((currentEventCompositeSize + currentSize.get()) < maxSize) || isEmpty())) { synchronized (lock) { - if (semaphore.availablePermits() == 0 && ((currentEventCompositeSize + currentSize.get()) < maxSize) || isEmpty()) { + if (semaphore.availablePermits() == 0 && (((currentEventCompositeSize + currentSize.get()) < maxSize) || isEmpty())) { semaphore.release(); } }