In these examples we don’t unlock() in finally block, just want to understand if it’s a norm to unlock in finally only if developer is expecting any error or is it a good practice to always unlock in finally.
Hi @Abhishek_Kalyan,
Thank you so much for reaching out to us. Since you already know that we throws
different Exception
s when we are developing a library but when we are using that library in our code then we always use try
-catch
block. If you write unblock()
within or outside the finally
it is pretty much the same thing but it has to be used after catch
block and do make sure that the object from which you are calling unblock()
is initialized, so don’t want to get NullPointerException
.
If there is any confusion please do let me know. Thanks.