users@jersey.java.net

[Jersey] Re: Strage issue with Jersey 2.8 and OSGi

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Tue, 3 Jun 2014 13:44:21 +0200

Forwarding to proper mailing list alias.

Marek

On 02 Jun 2014, at 21:14, Philipp Marx <smigfu_at_googlemail.com> wrote:

> Hi,
>
> I have upgraded my OSGi product from Jersey 1.7 to 2.8. It took me a while but finally everything is up and running. There is one issue though I see remaining with my HK2-Factories. It seems like they are creating endlessly classes of type "com.sun.Proxy" which are never being unloaded, thus flooding my PerGen space.
>
> An example factory looks like this:
>
> @Provider
>
> public class RequestContextFactory implements Factory<RequestContext>
>
> {
>
> @Inject
>
> private javax.inject.Provider<HttpHeaders> httpHeaders;
>
>
>
> @Inject
>
> private javax.inject.Provider<UriInfo> uriInfo;
>
>
>
> @Inject
>
> private javax.inject.Provider<SecurityContext> securityContext;
>
>
>
> @Inject
>
> private javax.inject.Provider<Request> request;
>
>
>
> @Override
>
> public void dispose(final RequestContext instance)
>
> {
>
> }
>
>
>
> @Override
>
> @PerThread
>
> public RequestContext provide()
>
> {
>
> final String requestId = httpHeaders.get().getHeaderString("x-request-id");
>
> final Principal principal = securityContext.get().getUserPrincipal();
>
>
>
> final RequestContext requestContext = new RequestContext(requestId, principal);
>
>
>
> requestContext.setRequestInfo(UriInfo.class, uriInfo.get());
>
> requestContext.setRequestInfo(Request.class, request.get());
>
> requestContext.setRequestInfo(HttpHeaders.class, httpHeaders.get());
>
> requestContext.setRequestInfo(Principal.class, principal);
>
>
>
> return requestContext;
>
>
> }
>
> Anybody has an idea what could be going wrong?
>
> Thanks.
>
>
> Cheers
> Philipp