You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an issue because Micrometer's SimpleObservationRegistry keeps the observation scope inside a ThreadLocal variable in SimpleObservationRegistry.java#L30:
We've identified a memory leak in
ThreadLocal
when the application endpoint returns with an exception. E.g.:It happens because in case of exceptions, the observation is started twice in:
jersey/ext/micrometer/src/main/java/org/glassfish/jersey/micrometer/server/ObservationRequestEventListener.java
Lines 67 to 72 in 619ebef
And:
jersey/ext/micrometer/src/main/java/org/glassfish/jersey/micrometer/server/ObservationRequestEventListener.java
Lines 73 to 75 in 619ebef
This is an issue because Micrometer's
SimpleObservationRegistry
keeps the observation scope inside aThreadLocal
variable in SimpleObservationRegistry.java#L30:The instance of
Scope
class contains a pointer to a previous scope SimpleObservation.java#L285:And these 2 things are updated in SimpleObservation.java#L290-L291
Now, each request that ends with an exception causes this linked list of observations to grow, because the code in:
jersey/ext/micrometer/src/main/java/org/glassfish/jersey/micrometer/server/ObservationRequestEventListener.java
Lines 83 to 91 in 619ebef
Here is an example test that reproduces the issue: 2.x...adpaste:jersey:memory_leak
The text was updated successfully, but these errors were encountered: