diff --git a/jpos/src/main/java/org/jpos/transaction/Context.java b/jpos/src/main/java/org/jpos/transaction/Context.java index 82ecccf92c..fc2953fd61 100644 --- a/jpos/src/main/java/org/jpos/transaction/Context.java +++ b/jpos/src/main/java/org/jpos/transaction/Context.java @@ -195,7 +195,8 @@ public synchronized T get (Object key, long timeout) { (now = System.currentTimeMillis()) < end) { try { - this.wait (end - now); + if (end > now) + this.wait (end - now); } catch (InterruptedException ignored) { } } return obj; diff --git a/jpos/src/main/java/org/jpos/util/BlockingQueue.java b/jpos/src/main/java/org/jpos/util/BlockingQueue.java index 36ba37024c..9cd861d88c 100644 --- a/jpos/src/main/java/org/jpos/util/BlockingQueue.java +++ b/jpos/src/main/java/org/jpos/util/BlockingQueue.java @@ -79,7 +79,8 @@ public synchronized Object dequeue (long timeout) long maxTime = System.currentTimeMillis() + timeout; try { while (queue.size() == 0 && System.currentTimeMillis() < maxTime) { - wait (timeout); + if (timeout > 0L) + wait (timeout); if (closed) throw new Closed(); } diff --git a/jpos/src/main/java/org/jpos/util/DirPoll.java b/jpos/src/main/java/org/jpos/util/DirPoll.java index 955abba88b..43e921e428 100644 --- a/jpos/src/main/java/org/jpos/util/DirPoll.java +++ b/jpos/src/main/java/org/jpos/util/DirPoll.java @@ -279,7 +279,7 @@ public void run() { } else { synchronized (shutdownMonitor) { - if (!shutdown) { + if (!shutdown && pollInterval > 0L) { shutdownMonitor.wait(pollInterval); } } @@ -289,7 +289,7 @@ public void run() { Logger.log (new LogEvent (this, "dirpoll", e)); try { synchronized (shutdownMonitor) { - if (!shutdown) { + if (!shutdown && pollInterval > 0L) { shutdownMonitor.wait(pollInterval * 10); } } @@ -458,7 +458,8 @@ else if (processor instanceof Processor) { synchronized (shutdownMonitor) { if (!shutdown) { try { - shutdownMonitor.wait(pollInterval * 10); // retry delay (pollInterval defaults to 100ms) + if (pollInterval > 0L) + shutdownMonitor.wait(pollInterval * 10); // retry delay (pollInterval defaults to 100ms) } catch (InterruptedException ie) { } }