Skip to main content

For review: Issue 35, agent interruptions

5 replies [Last post]
bkurotsu
Offline
Joined: 2004-12-13

Please review the two possible fixes and give your opinion. One fix is in each file. We only need one of them. The intent is to clear the interrupted flag of the thread before completing the test.

https://jtharness.dev.java.net/source/browse/jtharness?rev=809&view=rev

I prefer the fix in Agent.java, so that the fix occurs in the general case, rather than just in a socket type connection (which is the second proposed fix).

For reference, here is the relevant Thread API:
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#interrupted()

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
bkurotsu
Offline
Joined: 2004-12-13

Integrated.

sergey_borodin
Offline
Joined: 2006-10-20

Hello everybody.
Please, read my notes below

From one point of view, first case (fixing in Agent) is better as it allows to fix this problem for any implementation of Connection interface.
But from another side, we can think about this bug as problem in SocketConnection(as it doesn't throws InterruptedException when should).

May be, third proposed by Volker Simonis variant is the best?

It is about to insert following code in SocketConnection.waitUntilClosed() method:

"
finally {
timer.cancel(e);
if (Thread.interrupted()) {
throw new InterruptedException();
}
}
"

Thanks,
Sergey

bkurotsu
Offline
Joined: 2004-12-13

Maybe it is best to do both fixes then. Correct exception is thrown, will actually be caught in Agent by that catch block. But the Agent code will also check to clear the interrupted flag before starting the next test, which hopefully ensure that it stays fixed with other connection classes.

bkurotsu
Offline
Joined: 2004-12-13

So what do we think?

sergey_borodin
Offline
Joined: 2006-10-20

Sorry for delay,

yes, I'm agree with fix in both places.

Thanks,
Sergey