Program: 29011
Project: 29011
Buggy source:
/** 
 * Called by EJBLocalHome proxy.
 */
public Object invoke(Object proxy,Method method,Object[] args) throws Throwable {
  ClassLoader originalClassLoader=null;
  try {
    ((BaseContainer)getContainer()).onEnteringContainer();
    if (Thread.currentThread().getContextClassLoader() != getContainer().getClassLoader()) {
      originalClassLoader=Utility.setContextClassLoader(getContainer().getClassLoader());
    }
    Class methodClass=method.getDeclaringClass();
    if (methodClass == java.lang.Object.class) {
      return InvocationHandlerUtil.invokeJavaObjectMethod(this,method,args);
    }
 else     if (methodClass == IndirectlySerializable.class) {
      return this.getSerializableObjectFactory();
    }
 else     if (handleSpecialEJBLocalHomeMethod(method,methodClass)) {
      return invokeSpecialEJBLocalHomeMethod(method,methodClass,args);
    }
    InvocationInfo invInfo=(InvocationInfo)invocationInfoMap_.get(method,((args != null) ? args.length : 0));
    if (invInfo == null) {
      throw new IllegalStateException("String_Node_Str" + method);
    }
    if ((methodClass == javax.ejb.EJBLocalHome.class) || invInfo.ejbIntfOverride) {
      super.remove(args[0]);
      return null;
    }
 else     if (methodClass == GenericEJBLocalHome.class) {
      EJBLocalObjectImpl localImpl=createEJBLocalBusinessObjectImpl((String)args[0]);
      return localImpl.getClientObject((String)args[0]);
    }
    EJBLocalObjectImpl localObjectImpl=null;
    Object returnValue=null;
    if (invInfo.startsWithCreate) {
      localObjectImpl=createEJBLocalObjectImpl();
      if (localObjectImpl != null) {
        returnValue=localObjectImpl.getClientObject();
      }
    }
    if (!isStatelessSession_) {
      if (invInfo.targetMethod1 == null) {
        Object[] params=new Object[]{invInfo.ejbName,"String_Node_Str",invInfo.method.toString()};
        String errorMsg=localStrings.getLocalString("String_Node_Str","String_Node_Str",params);
        throw new EJBException(errorMsg);
      }
      EjbInvocation inv=((BaseContainer)getContainer()).createEjbInvocation();
      inv.isLocal=true;
      inv.isHome=true;
      inv.method=method;
      inv.clientInterface=localHomeIntfClass_;
      inv.transactionAttribute=invInfo.txAttr;
      inv.securityPermissions=invInfo.securityPermissions;
      inv.invocationInfo=invInfo;
      if (localObjectImpl != null && invInfo.startsWithCreate) {
        inv.ejbObject=(EJBLocalRemoteObject)localObjectImpl;
      }
      try {
        container.preInvoke(inv);
        if (invInfo.startsWithCreate) {
          Object ejbCreateReturnValue=invokeTargetBeanMethod(container,invInfo.targetMethod1,inv,inv.ejb,args);
          postCreate(container,inv,invInfo,ejbCreateReturnValue,args);
          if (inv.ejbObject != null) {
            returnValue=((EJBLocalObjectImpl)inv.ejbObject).getClientObject();
          }
        }
 else         if (invInfo.startsWithFindByPrimaryKey) {
          returnValue=container.invokeFindByPrimaryKey(invInfo.targetMethod1,inv,args);
        }
 else         if (invInfo.startsWithFind) {
          Object pKeys=invokeTargetBeanMethod(container,invInfo.targetMethod1,inv,inv.ejb,args);
          returnValue=container.postFind(inv,pKeys,null);
        }
 else {
          returnValue=invokeTargetBeanMethod(container,invInfo.targetMethod1,inv,inv.ejb,args);
        }
      }
 catch (      InvocationTargetException ite) {
        inv.exception=ite.getCause();
      }
catch (      Throwable c) {
        inv.exception=c;
      }
 finally {
        container.postInvoke(inv);
      }
      if (inv.exception != null) {
        InvocationHandlerUtil.throwLocalException(inv.exception,method.getExceptionTypes());
      }
    }
    return returnValue;
  }
  finally {
    if (originalClassLoader != null) {
      Utility.setContextClassLoader(originalClassLoader);
    }
    ((BaseContainer)getContainer()).onLeavingContainer();
  }
}

Fixed version (ground truth):
/** 
 * Called by EJBLocalHome proxy.
 */
public Object invoke(Object proxy,Method method,Object[] args) throws Throwable {
  ClassLoader originalClassLoader=null;
  try {
    ((BaseContainer)getContainer()).onEnteringContainer();
    if (Thread.currentThread().getContextClassLoader() != getContainer().getClassLoader()) {
      originalClassLoader=Utility.setContextClassLoader(getContainer().getClassLoader());
    }
    Class methodClass=method.getDeclaringClass();
    if (methodClass == java.lang.Object.class) {
      return InvocationHandlerUtil.invokeJavaObjectMethod(this,method,args);
    }
 else     if (methodClass == IndirectlySerializable.class) {
      return this.getSerializableObjectFactory();
    }
 else     if (handleSpecialEJBLocalHomeMethod(method,methodClass)) {
      return invokeSpecialEJBLocalHomeMethod(method,methodClass,args);
    }
    InvocationInfo invInfo=(InvocationInfo)invocationInfoMap_.get(method,((args != null) ? args.length : 0));
    if (invInfo == null) {
      throw new IllegalStateException("String_Node_Str" + method);
    }
    if ((methodClass == javax.ejb.EJBLocalHome.class) || invInfo.ejbIntfOverride) {
      super.remove(args[0]);
      return null;
    }
 else     if (methodClass == GenericEJBLocalHome.class) {
      EJBLocalObjectImpl localImpl=createEJBLocalBusinessObjectImpl((String)args[0]);
      return localImpl.getClientObject((String)args[0]);
    }
    EJBLocalObjectImpl localObjectImpl=null;
    Object returnValue=null;
    if (invInfo.startsWithCreate) {
      localObjectImpl=createEJBLocalObjectImpl();
      if (localObjectImpl != null) {
        returnValue=localObjectImpl.getClientObject();
      }
    }
    if (!isStatelessSession_) {
      if (invInfo.targetMethod1 == null) {
        Object[] params=new Object[]{invInfo.ejbName,"String_Node_Str",invInfo.method.toString()};
        String errorMsg=localStrings.getLocalString("String_Node_Str","String_Node_Str",params);
        throw new EJBException(errorMsg);
      }
      EjbInvocation inv=((BaseContainer)getContainer()).createEjbInvocation();
      inv.isLocal=true;
      inv.isHome=true;
      inv.method=method;
      inv.clientInterface=localHomeIntfClass_;
      inv.transactionAttribute=invInfo.txAttr;
      inv.invocationInfo=invInfo;
      if (localObjectImpl != null && invInfo.startsWithCreate) {
        inv.ejbObject=(EJBLocalRemoteObject)localObjectImpl;
      }
      try {
        container.preInvoke(inv);
        if (invInfo.startsWithCreate) {
          Object ejbCreateReturnValue=invokeTargetBeanMethod(container,invInfo.targetMethod1,inv,inv.ejb,args);
          postCreate(container,inv,invInfo,ejbCreateReturnValue,args);
          if (inv.ejbObject != null) {
            returnValue=((EJBLocalObjectImpl)inv.ejbObject).getClientObject();
          }
        }
 else         if (invInfo.startsWithFindByPrimaryKey) {
          returnValue=container.invokeFindByPrimaryKey(invInfo.targetMethod1,inv,args);
        }
 else         if (invInfo.startsWithFind) {
          Object pKeys=invokeTargetBeanMethod(container,invInfo.targetMethod1,inv,inv.ejb,args);
          returnValue=container.postFind(inv,pKeys,null);
        }
 else {
          returnValue=invokeTargetBeanMethod(container,invInfo.targetMethod1,inv,inv.ejb,args);
        }
      }
 catch (      InvocationTargetException ite) {
        inv.exception=ite.getCause();
      }
catch (      Throwable c) {
        inv.exception=c;
      }
 finally {
        container.postInvoke(inv);
      }
      if (inv.exception != null) {
        InvocationHandlerUtil.throwLocalException(inv.exception,method.getExceptionTypes());
      }
    }
    return returnValue;
  }
  finally {
    if (originalClassLoader != null) {
      Utility.setContextClassLoader(originalClassLoader);
    }
    ((BaseContainer)getContainer()).onLeavingContainer();
  }
}