Beh01der / EasyFlow

EasyFlow - Simple and lightweight Finite State Machine for Java
http://datasymphony.com.au/open-source/easyflow
Apache License 2.0
444 stars 86 forks source link

Do not swallow interrupts in awaitTermination #24

Closed mpontes closed 8 years ago

mpontes commented 8 years ago

awaitTermination in StatefulContext seems like it's about to do the right thing and put back the thread's interrupted bit if it gets interrupted while waiting, but instead it calls the wrong method*. This means that once awaitTermination, calling code will have no idea the thread was interrupted.

This PR fixes this by putting the thread's interrupt flag back, so calling code can do something with this information if it wants.

* - Regardless of intention, this has to be the wrong method because Thread.interrupted() is 100% guaranteed to do nothing in this case, the thread's interrupted state just got reset as we're catching InterruptedException, Thread.interrupted() will just return false and not change anything.

Beh01der commented 8 years ago

Thanks for the contribution, mate.