eclipse-ee4j / glassfish

Eclipse GlassFish
https://eclipse-ee4j.github.io/glassfish/
386 stars 144 forks source link

LazyMPMProvider does not release disposed endpoints #19096

Closed glassfishrobot closed 11 years ago

glassfishrobot commented 12 years ago

package com.sun.xml.ws.api.server;

Memory leak after undeployment of an ear.

deploy an ear with web services and jpa invoke at least one ws which uses jpa deploy the same ear again

=> the first deployed ear is not properly undeployed. (VisualVM is showing two instances of EarClassLoader

It's caused by unreleased but already disposed endpoints.

my patch performs some cleanup when registering an endpoint. I bet there is a proper solution, but this works.

public void registerEndpoint(final WSEndpointScopeChangeListener wsEndpoint) {
        endpointsWaitingForMOM.add(wsEndpoint);
        if (!isProviderInDefaultScope())
            wsEndpoint.scopeChanged(scope);

        // remove disposed end points
        for (final WSEndpointScopeChangeListener wse : new ArrayList<WSEndpointScopeChangeListener>(
endpointsWaitingForMOM)) {
            Boolean disposed = (Boolean) getMember(wse, wse.getClass(), "disposed");
            if (Boolean.TRUE.equals(disposed)) {
endpointsWaitingForMOM.remove(wse);
            }
        }

    }

    private static Object getMember(Object reference, Class<?> clazz, String memberName)  {
        try {
            final Field memberField = clazz.getDeclaredField(memberName);
            memberField.setAccessible(true);
            final Object object = memberField.get(reference);
            return object;
        } catch (NoSuchFieldException nsfe) {
            if (clazz.getSuperclass() == null)
return null;
            return getMember(reference, clazz.getSuperclass(), memberName);
        } catch (Exception e) {
        }
        return null;
    }

Affected Versions

[3.1.2]

glassfishrobot commented 6 years ago
glassfishrobot commented 11 years ago

@glassfishrobot Commented shreedhar_ganapathy said: -> Deployment -> Hong for further eval.

glassfishrobot commented 11 years ago

@glassfishrobot Commented @honghzzhang said: Assigning to the webservices team to follow up on this to see we can apply the patch in the webservices code to properly clean up endpoints for undeployment.

glassfishrobot commented 11 years ago

@glassfishrobot Commented @lukasj said: http://java.net/projects/glassfish/sources/svn/revision/59263

glassfishrobot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA GLASSFISH-19096

glassfishrobot commented 12 years ago

@glassfishrobot Commented Reported by bebbo

glassfishrobot commented 11 years ago

@glassfishrobot Commented Marked as fixed on Thursday, February 7th 2013, 6:26:33 am