Remove Observation.Context from WebClient request #32198
Description
Have a running app since 3 years in production without any issue. Experienced a memory leak when bumped Spring dependencies and have now traced it down to a single library: spring-webflux 6.1.1 -> 6.1.2 (no other code change)
It seems like their is a circular dependency between ClientRequestObservationContext and ClientRequest.Builder that cannot be garbage collected. The behaviour is deterministic in the sense that I managed to recreate the issue multiple times, it takes a couple of hours before running out of heap space. One instance of the application is quite heavy used with 50-100 requests / s and lots of downstream calls to other MicroServices using WebClient where the issue seems to be.
Changes that I think could be related:
- b878526#diff-3eb216adea96b2aa6651e8b1522b4c6b18a5271698d4478ac7b920eb90bbdfbe
- Improve "active" metrics handling in WebClient observations #31702
Please let me know if I can provide more information, first time posting a bug report here.
// Erik
Have done an heap dump multiple times and retained memory increasing for the specified types. Attaching a print screen of the heap dump:
Activity