Program: 66216
Project: 66216
Buggy source:
/** 
 * INTERNAL: This method will return the MapKeyLookupResult instance to be used to  store/retrieve the global helper context for a given application. OC4J classLoader levels:  0 - APP.web (servlet/jsp) or APP.wrapper (ejb) 1 - APP.root (parent for helperContext) 2 - default.root 3 - system.root 4 - oc4j.10.1.3 (remote EJB) or org.eclipse.persistence:11.1.1.0.0 5 - api:1.4.0 6 - jre.extension:0.0.0 7 - jre.bootstrap:1.5.0_07 (with various J2SE versions)
 * @return MapKeyLookupResult wrapping the application classloader for OC4J,the application name for WebLogic and WebSphere, the archive file  name for JBoss - if available; otherwise a MapKeyLookupResult  wrapping Thread.currentThread().getContextClassLoader()
 */
private static MapKeyLookupResult getContextMapKey(ClassLoader classLoader,String classLoaderName){
  if (classLoaderName.startsWith(OC4J_CLASSLOADER_NAME)) {
    if ((classLoader.getParent() != null) && ((classLoader.toString().indexOf(SDOConstants.CLASSLOADER_WEB_FRAGMENT) != -1) || (classLoader.toString().indexOf(SDOConstants.CLASSLOADER_EJB_FRAGMENT) != -1))) {
      classLoader=classLoader.getParent();
    }
    return new MapKeyLookupResult(classLoader);
  }
  if (classLoaderName.contains(WLS_CLASSLOADER_NAME)) {
    Object executeThread=getExecuteThread();
    if (executeThread != null) {
      try {
        Method getMethod=PrivilegedAccessHelper.getPublicMethod(executeThread.getClass(),WLS_APPLICATION_NAME_GET_METHOD_NAME,WLS_PARAMETER_TYPES,false);
        Object appName=PrivilegedAccessHelper.invokeMethod(getMethod,executeThread);
        if (appName == null && appResolver != null) {
          appName=appResolver.getApplicationName();
        }
        if (appName != null) {
          return new MapKeyLookupResult(appName.toString(),classLoader);
        }
      }
 catch (      Exception e) {
        throw SDOException.errorInvokingWLSMethodReflectively(WLS_APPLICATION_NAME_GET_METHOD_NAME,WLS_EXECUTE_THREAD,e);
      }
    }
    return new MapKeyLookupResult(classLoader);
  }
  if (classLoaderName.contains(WAS_CLASSLOADER_NAME)) {
    return getContextMapKeyForWAS(classLoader);
  }
  if (classLoaderName.contains(JBOSS_CLASSLOADER_NAME)) {
    return getContextMapKeyForJBoss(classLoader);
  }
  return new MapKeyLookupResult(classLoader);
}

Fixed version (ground truth):
/** 
 * INTERNAL: This method will return the MapKeyLookupResult instance to be used to  store/retrieve the global helper context for a given application. OC4J classLoader levels:  0 - APP.web (servlet/jsp) or APP.wrapper (ejb) 1 - APP.root (parent for helperContext) 2 - default.root 3 - system.root 4 - oc4j.10.1.3 (remote EJB) or org.eclipse.persistence:11.1.1.0.0 5 - api:1.4.0 6 - jre.extension:0.0.0 7 - jre.bootstrap:1.5.0_07 (with various J2SE versions)
 * @return MapKeyLookupResult wrapping the application classloader for OC4J,the application name for WebLogic and WebSphere, the archive file  name for JBoss - if available; otherwise a MapKeyLookupResult  wrapping Thread.currentThread().getContextClassLoader()
 */
private static MapKeyLookupResult getContextMapKey(ClassLoader classLoader,String classLoaderName){
  if (classLoaderName.startsWith(OC4J_CLASSLOADER_NAME)) {
    if ((classLoader.getParent() != null) && ((classLoader.toString().indexOf(SDOConstants.CLASSLOADER_WEB_FRAGMENT) != -1) || (classLoader.toString().indexOf(SDOConstants.CLASSLOADER_EJB_FRAGMENT) != -1))) {
      classLoader=classLoader.getParent();
    }
    return new MapKeyLookupResult(classLoader);
  }
  if (classLoaderName.contains(WLS_CLASSLOADER_NAME)) {
    Object appName=null;
    Object executeThread=getExecuteThread();
    if (executeThread != null) {
      try {
        Method getMethod=PrivilegedAccessHelper.getPublicMethod(executeThread.getClass(),WLS_APPLICATION_NAME_GET_METHOD_NAME,WLS_PARAMETER_TYPES,false);
        appName=PrivilegedAccessHelper.invokeMethod(getMethod,executeThread);
      }
 catch (      Exception e) {
        throw SDOException.errorInvokingWLSMethodReflectively(WLS_APPLICATION_NAME_GET_METHOD_NAME,WLS_EXECUTE_THREAD,e);
      }
    }
    if (appName == null && appResolver != null) {
      appName=appResolver.getApplicationName();
    }
    if (appName != null) {
      return new MapKeyLookupResult(appName.toString(),classLoader);
    }
    return new MapKeyLookupResult(classLoader);
  }
  if (classLoaderName.contains(WAS_CLASSLOADER_NAME)) {
    return getContextMapKeyForWAS(classLoader);
  }
  if (classLoaderName.contains(JBOSS_CLASSLOADER_NAME)) {
    return getContextMapKeyForJBoss(classLoader);
  }
  return new MapKeyLookupResult(classLoader);
}