Yes.
The finally
point should ensure that some kind of cleanup code runs regardless of which path the code uses to exit the try
block. This happens during a normal return, when an exception is thrown and caught, and when an exception is thrown that does not fall into this try
block. The only thing that will prevent its execution is if the program cannot leave the try
block at all; an infinite loop inside it or a process that is somehow killed, which prevents this normal processing or something in that order. Iām sure even if you exit the process from inside the try
block, which will be executed by the finally
block before the process really dies.
source share