njnu-seafish opened a new issue, #17469: URL: https://github.com/apache/dolphinscheduler/issues/17469
### Search before asking - [x] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened 1, the preHandle method trigger the following logic: ThreadLocalContext.getTimezoneThreadLocal().set(user.getTimeZone()); 2,then the postHandle method trigger the following logic: ThreadLocalContext.getTimezoneThreadLocal().remove(); 3, However, if the Controller method throws an exception, the postHandle method will not be called. If this situation occurs frequently, a memory leak problem will occur. ### What you expected to happen Perform resource cleanup operations in the afterCompletion method, because the afterCompletion method is executed after the entire request processing is complete, regardless of whether the request was handled successfully (i.e., whether an exception was thrown or not). ### How to reproduce 1, Controller throws an exception 2, Frequently logging in and accessing the controller 3, postHandle is only called after the Controller is successfully executed. If the Controller throws an exception, postHandle will not be executed, resulting in the ThreadLocal not being cleaned up, which may lead to memory leaks or dirty data. ### Anything else _No response_ ### Version dev ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
