DIRMINA-1140 - detecting specific case of InterruptedException in NioDatagramAcceptor - #75
Merged
Merged
Conversation
the-thing
force-pushed
the
socket-acceptor-dispose
branch
from
October 2, 2026 07:34
a1c12ed to
0c659be
Compare
the-thing
force-pushed
the
socket-acceptor-dispose
branch
from
October 2, 2026 07:45
0c659be to
d55fa1b
Compare
Contributor
|
Looks good to me. And thanks for the cleanup of the code I pushed in a hurry ;-) |
Member
Author
|
Thanks. No probs. When I see a bug or something to improve I see bread on the table ;). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix for DIRMINA-1140
I was able to retrofit JIRA's attached minimal working example into a test case. The title is slightly wrong as this can happen for a single acceptor that is being disposed.
org.apache.mina.core.service.AbstractIoService#dispose(boolean)is the root cause. When a nulljava.util.concurrent.Executoris passed inorg.apache.mina.core.service.AbstractIoService#AbstractIoServicecreates a newjava.util.concurrent.Executors#newCachedThreadPool()and the service is responsible for shutting it down during disposal.When
java.util.concurrent.ExecutorServiceis shut down it usually interrupts threads which leads tomina/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioDatagramAcceptor.java
Line 169 in b6739d2
Suggested fix is to check the flag if service is being disposed when
java.lang.InterruptedExceptionexception is caught and do not rethrow it. I checked and this doesn't happen fororg.apache.mina.transport.socket.nio.NioSocketAcceptoretc.Aleternative fixes:
use
java.util.concurrent.Semaphore#acquireUninterruptibly()instead ofjava.util.concurrent.Semaphore#acquire(), but since the thread was interrupted we probably want it to be responsive and do not attempt to acquire the lock (haven't tested this solution).completely ignore - catch without logging / throwing
InterruptedException. Not the best since if the custom Executor is passed toNioDatagramAcceptorand is shutdown before the unbind happened, it will lead to similar error, but in this case we actually want to throw it for the user to know about bad shutdown order (demo inorg.apache.mina.transport.socket.nio.NioDatagramAcceptorTest#shouldThrowExceptionWhenThreadIsInterruptedAndServiceIsNotDisposingcase)