You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "the-thing (via GitHub)" <gi...@apache.org> on 2026/10/02 07:17:19 UTC
[PR] DIRMINA-1140 - detecting specific case of `InterruptedException` in `NioDatagramAcceptor` [mina]
the-thing opened a new pull request, #75:
URL: https://github.com/apache/mina/pull/75
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 null `java.util.concurrent.Executor` is passed in `org.apache.mina.core.service.AbstractIoService#AbstractIoService` creates a new `java.util.concurrent.Executors#newCachedThreadPool()` and the service is responsible for shutting it down during disposal.
When `java.util.concurrent.ExecutorService` is shut down it usually interrupts threads which leads to https://github.com/apache/mina/blob/b6739d21e63f5541dcaecaff1b3b57993feeb9e3/mina-core/src/main/java/org/apache/mina/transport/socket/nio/NioDatagramAcceptor.java#L169 interrupted exception being thrown here.
Suggested fix is to check the flag if service is being disposed when `java.lang.InterruptedException` exception is caught and do not rethrow it. I checked and this doesn't happen for `org.apache.mina.transport.socket.nio.NioSocketAcceptor` etc.
Aleternative fixes:
- use `java.util.concurrent.Semaphore#acquireUninterruptibly()` instead of `java.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 to `NioDatagramAcceptor` and 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 in `org.apache.mina.transport.socket.nio.NioDatagramAcceptorTest#shouldThrowExceptionWhenThreadIsInterruptedAndServiceIsNotDisposing` case)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] DIRMINA-1140 - detecting specific case of `InterruptedException` in `NioDatagramAcceptor` [mina]
Posted by "elecharny (via GitHub)" <gi...@apache.org>.
elecharny commented on PR #75:
URL: https://github.com/apache/mina/pull/75#issuecomment-5951335449
Looks good to me.
And thanks for the cleanup of the code I pushed in a hurry ;-)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] DIRMINA-1140 - detecting specific case of `InterruptedException` in `NioDatagramAcceptor` [mina]
Posted by "the-thing (via GitHub)" <gi...@apache.org>.
the-thing commented on PR #75:
URL: https://github.com/apache/mina/pull/75#issuecomment-5966959666
Thanks. No probs. When I see a bug or something to improve I see bread on the table ;).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] DIRMINA-1140 - detecting specific case of `InterruptedException` in `NioDatagramAcceptor` [mina]
Posted by "the-thing (via GitHub)" <gi...@apache.org>.
the-thing merged PR #75:
URL: https://github.com/apache/mina/pull/75
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org