Well, I have no idea where or what @Transaction(Reuired) does (not standard
Java I don't think), but if you want to revert the ThreadLocal value back if an exception happen you will need to:
1) Cache a copy of the value as you enter the method.
2) Catch all exceptions, revert the value to the cached value
3) Probably re-throw the exception so if triggers any other exception handling mechanisms exist.