users@jersey.java.net

[Jersey] Re: HK2 classloader leak

From: cowwoc <cowwoc_at_bbs.darktech.org>
Date: Fri, 29 Nov 2013 11:48:00 -0500

If this is indeed an HK2 bug, it should be reported to the HK2 mailing
list instead of here.

Gili

On 29/11/2013 11:34 AM, Matyas Bene wrote:
>
> Not sure if my findings are correct, but during troubleshooting a
> classloader-leak seemingly related to jersey and
> com.fasterxml.jackson, I found the following (EMA screenshot attached):
>
> Jersey is using hk2 for Injection.
>
> Inside org.jvnet.hk2.internal.Utilities class we find a methodKeyCache
> field, which is a WeakHashMap.
>
> The key is a Class<?> (and so far so good), but the value is HashSet
> of MemberKey, where backingMember is a method instance, but which (in
> this case unfortunately), contains a hard-reference to a Class<?>
> instance (which happens to be the same as the key).
>
> This seems therefore a clear violation of the guideline described in
> the docs:
>
> *Implementation note:*The value objects in aWeakHashMapare held by
> ordinary strong references. Thus care should be taken to ensure that
> value objects do not strongly refer to their own keys, either directly
> or indirectly, since that will prevent the keys from being discarded.
>
> If this is by purpose, what is the proper way unloading the
> application? Initialization is currently done by extending
> ResourceConfig and registering my custom provider class class that
> again extends com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider.
>
> Thanks in advance.
>
> *Matyas Bene*
>
> IT Manager for Development and Architecture
>
> Phone +421 (907) 681816
>
> matyas.bene_at_ferratum.com <mailto:matyas.bene_at_ferratum.com>
>
> *Ferratum Slovakia s.r.o.*
>
> Jakubovo nám 19
>
> 811 09, Bratislava, Slovak Republic
>
> https://www.ferratum.sk/
>
> cid:image001.jpg_at_01CC7F83.C776D980
>