krzysztofslusarski / continuous-async-profiler

Spring boot library for continuous profiling with async-profiler
Apache License 2.0
30 stars 5 forks source link

"InterruptedException" should not be ignored #8

Closed wyhasany closed 3 years ago

wyhasany commented 3 years ago

InterruptedExceptions should never be ignored in the code, and simply logging the exception counts in this case as "ignoring". The throwing of the InterruptedException clears the interrupted state of the Thread, so if the exception is not handled properly the fact that the thread was interrupted will be lost. Instead, InterruptedExceptions should either be rethrown - immediately or after cleaning up the method's state - or the thread should be re-interrupted by calling Thread.interrupt() even if this is supposed to be a single-threaded application. Any other course of action risks delaying thread shutdown and loses the information that the thread was interrupted - probably without finishing its task.

//based on sonar (copy pasted message)