Problem Statement
At the moment Hub instances are stored in ThreadLocal variables. They are never cleaned up and thus cause servers like Tomcat to issue warnings as can be seen here #2074, here #420 and here #487. While there are mechanisms to clean up these leaks in Tomcat we should not rely on them and clean up instead.
|
private static final @NotNull ThreadLocal<IHub> currentHub = new ThreadLocal<>(); |
Solution Brainstorm
We may have to move away from ThreadLocal variables at some point to support Webflux and similar. Until then we could try and unset the ThreadLocal after a request is done (ServletRequestListener.requestDestroyed)
Problem Statement
At the moment Hub instances are stored in
ThreadLocalvariables. They are never cleaned up and thus cause servers like Tomcat to issue warnings as can be seen here #2074, here #420 and here #487. While there are mechanisms to clean up these leaks in Tomcat we should not rely on them and clean up instead.sentry-java/sentry/src/main/java/io/sentry/Sentry.java
Line 21 in 9f1af1c
Solution Brainstorm
We may have to move away from
ThreadLocalvariables at some point to support Webflux and similar. Until then we could try and unset theThreadLocalafter a request is done (ServletRequestListener.requestDestroyed)