glassfish
  1. glassfish
  2. GLASSFISH-19096

LazyMPMProvider does not release disposed endpoints

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.1.2
    • Fix Version/s: 4.0_b73
    • Component/s: web_services
    • Labels:
      None

      Description

      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;
          }
      

        Activity

        Hide
        shreedhar_ganapathy added a comment -

        -> Deployment
        -> Hong for further eval.

        Show
        shreedhar_ganapathy added a comment - -> Deployment -> Hong for further eval.
        Hide
        Hong Zhang added a comment -

        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.

        Show
        Hong Zhang added a comment - 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.
        Show
        Lukas Jungmann added a comment - http://java.net/projects/glassfish/sources/svn/revision/59263

          People

          • Assignee:
            Lukas Jungmann
            Reporter:
            bebbo
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: