Skip to content

Commit

Permalink
SMPPSession.close() waits for all extra threads to stop
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Thorvardarson committed Feb 18, 2012
1 parent 1907907 commit 179ac70
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions jsmpp/src/main/java/org/jsmpp/session/SMPPSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,20 @@ protected GenericMessageReceiverListener messageReceiverListener() {
return messageReceiverListener;
}

@Override
public void close()
{
super.close();

if(Thread.currentThread() != pduReaderWorker) {
try {
pduReaderWorker.join();
} catch (InterruptedException e) {
logger.warn("Interrupted while waiting for pduReaderWorker thread to exit");
}
}
}

@Override
protected void finalize() throws Throwable {
close();
Expand Down Expand Up @@ -602,6 +616,7 @@ private void readPDU() {
} catch (SocketTimeoutException e) {
notifyNoActivity();
} catch (IOException e) {
logger.warn("IOException while reading: {}", e.getMessage());
close();
}
}
Expand Down

0 comments on commit 179ac70

Please sign in to comment.