0

I am trying to build a SIMPLE test case to send to IBM to try to resolve this issue

I thought it would be simple to gin up a JUnit Test case or a little main app that made the calls and show that the MQ call never returned. I thought I'd use the Executor service, wrap my MQ call in a Callable and submit it to the executor service using Future.get() with timeout interval specified.

To be sure, the call times out, but the application won't die. If I use Assert.fail() or when the timeout exception is caught, it doesn't happen, although the stack trace of the timeout exception does print. I can only kill the program externally or by calling System.exit(). I'd rather not do either. Is there some way to kill the thread within the framework of the java.util.concurrent package?

This issue offers a solution but with the caveat

As long as you don't make uninterruptable blocking calls in your task

But that's exactly what I'm doing. Is there ANY way to kill a program that DOES call uninterruptable I/O from within?

Community
  • 1
  • 1
Steve Cohen
  • 4,679
  • 9
  • 51
  • 89
  • What I/O do you think is uninterruptable? I/O operations can be interrupted, but they will signal the interruption with a IOException rather than an InterruptedException. – Raedwald Jun 09 '14 at 21:32
  • @Raedwald - An asynchronous put call to Websphere MQ. As in my first link. Read the docs on java.util.concurrent.ExecutorService.shutdownNow(). They specifically mention IO that can't be interrupted. – Steve Cohen Jun 09 '14 at 21:37

1 Answers1

0

When dealing with external IO, the usual way of killing the process that does the connection is to close the socket connected to the distant server.

Doing so you will get an IO exception but the process will terminate and the thread from the pool will stop working.

Jean Logeart
  • 52,687
  • 11
  • 83
  • 118