Skip to content

Commit

Permalink
Terminate executor at shutdown time
Browse files Browse the repository at this point in the history
  • Loading branch information
ar committed Sep 17, 2023
1 parent a646ed5 commit 64c0704
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion jpos/src/main/java/org/jpos/iso/ISOServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.LockSupport;

Expand Down Expand Up @@ -236,7 +237,8 @@ private void shutdownServer () {
serverSocket.close ();
fireEvent(new ISOServerShutdownEvent(this));
}
} catch (IOException e) {
executor.awaitTermination(LONG_RELAX, TimeUnit.SECONDS);
} catch (IOException | InterruptedException e) {
fireEvent(new ISOServerShutdownEvent(this));
Logger.log (new LogEvent (this, "shutdown", e));
}
Expand Down Expand Up @@ -601,6 +603,7 @@ public void resetCounters () {
connectionCount.set(0);
lastTxn = 0l;
}

/**
* @return number of connections accepted by this server
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import java.io.EOFException;
import java.io.IOException;
import java.net.SocketTimeoutException;
import java.util.Properties;

import org.hamcrest.Description;
Expand Down Expand Up @@ -83,7 +84,7 @@ public void serverSideDisconnect() throws Exception {

isoServer.shutdown();

assertThrows(EOFException.class, () -> {
assertThrows(SocketTimeoutException.class, () -> {
clientChannel.receive();
}, "clientChannel should be closed");
}
Expand Down

0 comments on commit 64c0704

Please sign in to comment.