Skip to content

Commit

Permalink
Protect against NTP sending clock backward.
Browse files Browse the repository at this point in the history
  • Loading branch information
ar committed Nov 28, 2023
1 parent 5aaa249 commit d62cca5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion jpos/src/main/java/org/jpos/transaction/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ public synchronized <T> 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;
Expand Down
3 changes: 2 additions & 1 deletion jpos/src/main/java/org/jpos/util/BlockingQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
7 changes: 4 additions & 3 deletions jpos/src/main/java/org/jpos/util/DirPoll.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public void run() {
}
else {
synchronized (shutdownMonitor) {
if (!shutdown) {
if (!shutdown && pollInterval > 0L) {
shutdownMonitor.wait(pollInterval);
}
}
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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) {
}
}
Expand Down

0 comments on commit d62cca5

Please sign in to comment.