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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
