Program: 63447
Project: 63447
Buggy source:
/** 
 * Called by the container when an EntityManagerFactory is to be created.
 * @param info Metadata for use by the persistence provider
 * @return EntityManagerFactory for the persistence unitspecified by the metadata
 * @param properties A Map of integration-level properties for useby the persistence provider.
 */
public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info,Map properties){
  JavaSECMPInitializer.setIsInContainer(true);
  Map nonNullProperties=(properties == null) ? new HashMap() : properties;
  EntityManagerSetupImpl emSetupImpl=null;
  if (EntityManagerSetupImpl.mustBeCompositeMember(info)) {
    emSetupImpl=new EntityManagerSetupImpl(info.getPersistenceUnitName(),info.getPersistenceUnitName());
    emSetupImpl.predeploy(info,nonNullProperties);
  }
 else {
    boolean isNew=false;
    ClassTransformer transformer=null;
    String uniqueName=PersistenceUnitProcessor.buildPersistenceUnitName(info.getPersistenceUnitRootUrl(),info.getPersistenceUnitName());
    String sessionName=EntityManagerSetupImpl.getOrBuildSessionName(nonNullProperties,info,uniqueName);
synchronized (EntityManagerFactoryProvider.emSetupImpls) {
      emSetupImpl=EntityManagerFactoryProvider.getEntityManagerSetupImpl(sessionName);
      if (emSetupImpl == null) {
        emSetupImpl=new EntityManagerSetupImpl(uniqueName,sessionName);
        isNew=true;
        emSetupImpl.setIsInContainerMode(true);
        transformer=emSetupImpl.predeploy(info,nonNullProperties);
        EntityManagerFactoryProvider.addEntityManagerSetupImpl(sessionName,emSetupImpl);
      }
    }
    if (!isNew) {
      if (!uniqueName.equals(emSetupImpl.getPersistenceUnitUniqueName())) {
        throw PersistenceUnitLoadingException.sessionNameAlreadyInUse(sessionName,uniqueName,emSetupImpl.getPersistenceUnitUniqueName());
      }
      boolean undeployed=false;
synchronized (emSetupImpl) {
        if (emSetupImpl.isUndeployed()) {
          undeployed=true;
        }
 else {
          transformer=emSetupImpl.predeploy(emSetupImpl.getPersistenceUnitInfo(),nonNullProperties);
        }
      }
      if (undeployed) {
        return createContainerEntityManagerFactory(info,properties);
      }
    }
    if (transformer != null) {
      info.addTransformer(transformer);
    }
  }
  EntityManagerFactoryImpl factory=null;
  try {
    factory=new EntityManagerFactoryImpl(emSetupImpl,nonNullProperties);
    emSetupImpl.preInitializeCanonicalMetamodel(factory);
    if (emSetupImpl.shouldGetSessionOnCreateFactory(nonNullProperties)) {
      factory.getDatabaseSession();
    }
    return factory;
  }
 catch (  RuntimeException ex) {
    if (factory != null) {
      factory.close();
    }
 else {
      emSetupImpl.undeploy();
    }
    throw ex;
  }
}

Fixed version (ground truth):
/** 
 * Called by the container when an EntityManagerFactory is to be created.
 * @param info Metadata for use by the persistence provider
 * @return EntityManagerFactory for the persistence unitspecified by the metadata
 * @param properties A Map of integration-level properties for useby the persistence provider.
 */
public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info,Map properties){
  return createContainerEntityManagerFactoryImpl(info,properties,true);
}