Yes, if you "return" or "throw" in a "finally" block, any pending exception is lost. Therefore,
you should never "return" or "throw" in a "finally" block.
It is pretty easy to remember not to use "return" or "throw" in a "finally". But it is also necessary to ensure that any method calls in your "finally" cannot reasonably throw an exception, because that exception would hide the pending exception.
To do this: -
Keep code in "finally" as simple as possibleUse try..catch, inside the "finally", to handle any exceptions that occur. Usually, there is little you can do beyond logging the exception, as you already have another exception pending.