Program: 68881
Project: 68881
Buggy source:
/** 
 * Perform any steps necessary prior to actual deployment.  This includes any steps in the session creation that do not require the real loaded domain classes. The first call to this method caches persistenceUnitInfo which is reused in the following calls. Note that in JSE case factoryCount is NOT incremented on the very first call  (by JavaSECMPInitializer.callPredeploy, typically in preMain). That provides 1 to 1 correspondence between factoryCount and the number of open factories. In case factoryCount > 0 the method just increments factoryCount. factory == 0 triggers creation of a new session. This method and undeploy - the only methods altering factoryCount - should be synchronized.
 * @return A transformer (which may be null) that should be plugged into the properclassloader to allow classes to be transformed as they get loaded.
 * @see #deploy(ClassLoader,Map)
 */
public synchronized ClassTransformer predeploy(PersistenceUnitInfo info,Map extendedProperties){
  if (state == STATE_DEPLOY_FAILED) {
    throw new PersistenceException(EntityManagerSetupException.cannotPredeploy(persistenceUnitInfo.getPersistenceUnitName(),state));
  }
  if (state == STATE_PREDEPLOYED || state == STATE_DEPLOYED) {
    session.log(SessionLog.FINEST,SessionLog.PROPERTIES,"String_Node_Str",new Object[]{getPersistenceUnitInfo().getPersistenceUnitName(),state,factoryCount});
    factoryCount++;
    session.log(SessionLog.FINEST,SessionLog.PROPERTIES,"String_Node_Str",new Object[]{getPersistenceUnitInfo().getPersistenceUnitName(),state,factoryCount});
    return null;
  }
 else   if (state == STATE_INITIAL || state == STATE_UNDEPLOYED) {
    persistenceUnitInfo=info;
  }
  try {
    ClassLoader privateClassLoader=persistenceUnitInfo.getNewTempClassLoader();
    predeployProperties=mergeMaps(extendedProperties,persistenceUnitInfo.getProperties());
    translateOldProperties(predeployProperties,null);
    String sessionsXMLStr=(String)predeployProperties.get(PersistenceUnitProperties.SESSIONS_XML);
    String sessionNameStr=(String)predeployProperties.get(PersistenceUnitProperties.SESSION_NAME);
    if (sessionsXMLStr != null) {
      isSessionLoadedFromSessionsXML=true;
    }
    session=new ServerSession(new Project(new DatabaseLogin()));
    setServerSessionName(predeployProperties);
    ClassLoader realClassLoader=persistenceUnitInfo.getClassLoader();
    updateServerPlatform(predeployProperties,realClassLoader);
    updateLoggers(predeployProperties,true,false,realClassLoader);
    session.log(SessionLog.FINEST,SessionLog.PROPERTIES,"String_Node_Str",new Object[]{getPersistenceUnitInfo().getPersistenceUnitName(),state,factoryCount});
    if (isSessionLoadedFromSessionsXML) {
      session.log(SessionLog.FINEST,SessionLog.PROPERTIES,"String_Node_Str",sessionsXMLStr,sessionNameStr);
      if (sessionNameStr == null) {
        throw new PersistenceException(EntityManagerSetupException.sessionNameNeedBeSpecified(info.getPersistenceUnitName(),sessionsXMLStr));
      }
      XMLSessionConfigLoader xmlLoader=new XMLSessionConfigLoader(sessionsXMLStr);
      Session tempSession=new SessionManager().getSession(xmlLoader,sessionNameStr,privateClassLoader,false,false);
      session.log(SessionLog.FINEST,SessionLog.PROPERTIES,"String_Node_Str",xmlLoader.getSessionName(),xmlLoader.getResourcePath());
      if (tempSession == null) {
        throw new PersistenceException(ValidationException.noSessionFound(sessionNameStr,sessionsXMLStr));
      }
      if (tempSession.isServerSession()) {
        session=(ServerSession)tempSession;
      }
 else {
        throw new PersistenceException(EntityManagerSetupException.sessionLoadedFromSessionsXMLMustBeServerSession(info.getPersistenceUnitName(),(String)predeployProperties.get(PersistenceUnitProperties.SESSIONS_XML),tempSession));
      }
      setServerSessionName(predeployProperties);
      updateServerPlatform(predeployProperties,privateClassLoader);
      updateLoggers(predeployProperties,true,false,privateClassLoader);
    }
    warnOldProperties(predeployProperties,session);
    session.getPlatform().setConversionManager(new JPAConversionManager());
    PersistenceUnitTransactionType transactionType=null;
    String transTypeString=getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.TRANSACTION_TYPE,predeployProperties,session);
    if (transTypeString != null) {
      transactionType=PersistenceUnitTransactionType.valueOf(transTypeString);
    }
 else     if (persistenceUnitInfo != null) {
      transactionType=persistenceUnitInfo.getTransactionType();
    }
    if (!isValidationOnly(predeployProperties,false) && persistenceUnitInfo != null && persistenceUnitInfo.getTransactionType() == PersistenceUnitTransactionType.JTA) {
      if (predeployProperties.get(PersistenceUnitProperties.JTA_DATASOURCE) == null && persistenceUnitInfo.getJtaDataSource() == null) {
        throw new PersistenceException(EntityManagerSetupException.jtaPersistenceUnitInfoMissingJtaDataSource(persistenceUnitInfo.getPersistenceUnitName()));
      }
    }
    if (state == STATE_INITIAL || state == STATE_UNDEPLOYED) {
      enableWeaving=true;
      isWeavingStatic=false;
      String weaving=getConfigPropertyAsString(PersistenceUnitProperties.WEAVING);
      if (weaving != null && weaving.equalsIgnoreCase("String_Node_Str")) {
        enableWeaving=false;
      }
 else       if (weaving != null && weaving.equalsIgnoreCase("String_Node_Str")) {
        isWeavingStatic=true;
      }
    }
    boolean throwExceptionOnFail="String_Node_Str".equalsIgnoreCase(EntityManagerFactoryProvider.getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.TOPLINK_ORM_THROW_EXCEPTIONS,predeployProperties,"String_Node_Str",session));
    ClassTransformer transformer=null;
    if (!isSessionLoadedFromSessionsXML) {
      processor=new MetadataProcessor(persistenceUnitInfo,session,privateClassLoader,enableWeaving);
      PersistenceUnitProcessor.processORMetadata(processor,privateClassLoader,session,throwExceptionOnFail);
      session.getProject().getLogin().setConnector(new DefaultConnector());
      if (session.getIntegrityChecker().hasErrors()) {
        session.handleException(new IntegrityException(session.getIntegrityChecker()));
      }
      if (enableWeaving) {
        boolean weaveChangeTracking="String_Node_Str".equalsIgnoreCase(EntityManagerFactoryProvider.getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.WEAVING_CHANGE_TRACKING,predeployProperties,"String_Node_Str",session));
        boolean weaveLazy="String_Node_Str".equalsIgnoreCase(EntityManagerFactoryProvider.getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.WEAVING_LAZY,predeployProperties,"String_Node_Str",session));
        boolean weaveFetchGroups="String_Node_Str".equalsIgnoreCase(EntityManagerFactoryProvider.getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.WEAVING_FETCHGROUPS,predeployProperties,"String_Node_Str",session));
        Collection entities=PersistenceUnitProcessor.buildEntityList(processor,privateClassLoader);
        transformer=TransformerFactory.createTransformerAndModifyProject(session,entities,privateClassLoader,weaveLazy,weaveChangeTracking,weaveFetchGroups);
      }
    }
 else {
      if (enableWeaving) {
        boolean weaveChangeTracking="String_Node_Str".equalsIgnoreCase(EntityManagerFactoryProvider.getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.WEAVING_CHANGE_TRACKING,predeployProperties,"String_Node_Str",session));
        boolean weaveLazy="String_Node_Str".equalsIgnoreCase(EntityManagerFactoryProvider.getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.WEAVING_LAZY,predeployProperties,"String_Node_Str",session));
        boolean weaveFetchGroups="String_Node_Str".equalsIgnoreCase(EntityManagerFactoryProvider.getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.WEAVING_FETCHGROUPS,predeployProperties,"String_Node_Str",session));
        Collection persistenceClasses=new ArrayList(session.getProject().getDescriptors().keySet());
        transformer=TransformerFactory.createTransformerAndModifyProject(session,persistenceClasses,privateClassLoader,weaveLazy,weaveChangeTracking,weaveFetchGroups);
      }
    }
    if (state != STATE_INITIAL || this.isInContainerMode()) {
      factoryCount++;
    }
    state=STATE_PREDEPLOYED;
    session.log(SessionLog.FINEST,SessionLog.PROPERTIES,"String_Node_Str",new Object[]{getPersistenceUnitInfo().getPersistenceUnitName(),state,factoryCount});
    if (isWeavingStatic) {
      return null;
    }
 else {
      return transformer;
    }
  }
 catch (  RuntimeException ex) {
    state=STATE_PREDEPLOY_FAILED;
    session=null;
    throw new PersistenceException(EntityManagerSetupException.predeployFailed(persistenceUnitInfo.getPersistenceUnitName(),ex));
  }
}

Fixed version (ground truth):
/** 
 * Perform any steps necessary prior to actual deployment.  This includes any steps in the session creation that do not require the real loaded domain classes. The first call to this method caches persistenceUnitInfo which is reused in the following calls. Note that in JSE case factoryCount is NOT incremented on the very first call  (by JavaSECMPInitializer.callPredeploy, typically in preMain). That provides 1 to 1 correspondence between factoryCount and the number of open factories. In case factoryCount > 0 the method just increments factoryCount. factory == 0 triggers creation of a new session. This method and undeploy - the only methods altering factoryCount - should be synchronized.
 * @return A transformer (which may be null) that should be plugged into the properclassloader to allow classes to be transformed as they get loaded.
 * @see #deploy(ClassLoader,Map)
 */
public synchronized ClassTransformer predeploy(PersistenceUnitInfo info,Map extendedProperties){
  if (state == STATE_DEPLOY_FAILED) {
    throw new PersistenceException(EntityManagerSetupException.cannotPredeploy(persistenceUnitInfo.getPersistenceUnitName(),state));
  }
  if (state == STATE_PREDEPLOYED || state == STATE_DEPLOYED) {
    session.log(SessionLog.FINEST,SessionLog.PROPERTIES,"String_Node_Str",new Object[]{getPersistenceUnitInfo().getPersistenceUnitName(),state,factoryCount});
    factoryCount++;
    session.log(SessionLog.FINEST,SessionLog.PROPERTIES,"String_Node_Str",new Object[]{getPersistenceUnitInfo().getPersistenceUnitName(),state,factoryCount});
    return null;
  }
 else   if (state == STATE_INITIAL || state == STATE_UNDEPLOYED) {
    persistenceUnitInfo=info;
  }
  try {
    ClassLoader privateClassLoader=persistenceUnitInfo.getNewTempClassLoader();
    predeployProperties=mergeMaps(extendedProperties,persistenceUnitInfo.getProperties());
    translateOldProperties(predeployProperties,null);
    String sessionsXMLStr=(String)predeployProperties.get(PersistenceUnitProperties.SESSIONS_XML);
    String sessionNameStr=(String)predeployProperties.get(PersistenceUnitProperties.SESSION_NAME);
    if (sessionsXMLStr != null) {
      isSessionLoadedFromSessionsXML=true;
    }
    session=new ServerSession(new Project(new DatabaseLogin()));
    setServerSessionName(predeployProperties);
    ClassLoader realClassLoader=persistenceUnitInfo.getClassLoader();
    updateServerPlatform(predeployProperties,realClassLoader);
    updateLoggers(predeployProperties,true,false,realClassLoader);
    updateProfiler(predeployProperties,realClassLoader);
    session.log(SessionLog.FINEST,SessionLog.PROPERTIES,"String_Node_Str",new Object[]{getPersistenceUnitInfo().getPersistenceUnitName(),state,factoryCount});
    if (isSessionLoadedFromSessionsXML) {
      session.log(SessionLog.FINEST,SessionLog.PROPERTIES,"String_Node_Str",sessionsXMLStr,sessionNameStr);
      if (sessionNameStr == null) {
        throw new PersistenceException(EntityManagerSetupException.sessionNameNeedBeSpecified(info.getPersistenceUnitName(),sessionsXMLStr));
      }
      XMLSessionConfigLoader xmlLoader=new XMLSessionConfigLoader(sessionsXMLStr);
      Session tempSession=new SessionManager().getSession(xmlLoader,sessionNameStr,privateClassLoader,false,false);
      session.log(SessionLog.FINEST,SessionLog.PROPERTIES,"String_Node_Str",xmlLoader.getSessionName(),xmlLoader.getResourcePath());
      if (tempSession == null) {
        throw new PersistenceException(ValidationException.noSessionFound(sessionNameStr,sessionsXMLStr));
      }
      if (tempSession.isServerSession()) {
        session=(ServerSession)tempSession;
      }
 else {
        throw new PersistenceException(EntityManagerSetupException.sessionLoadedFromSessionsXMLMustBeServerSession(info.getPersistenceUnitName(),(String)predeployProperties.get(PersistenceUnitProperties.SESSIONS_XML),tempSession));
      }
      setServerSessionName(predeployProperties);
      updateServerPlatform(predeployProperties,privateClassLoader);
      updateLoggers(predeployProperties,true,false,privateClassLoader);
    }
    warnOldProperties(predeployProperties,session);
    session.getPlatform().setConversionManager(new JPAConversionManager());
    PersistenceUnitTransactionType transactionType=null;
    String transTypeString=getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.TRANSACTION_TYPE,predeployProperties,session);
    if (transTypeString != null) {
      transactionType=PersistenceUnitTransactionType.valueOf(transTypeString);
    }
 else     if (persistenceUnitInfo != null) {
      transactionType=persistenceUnitInfo.getTransactionType();
    }
    if (!isValidationOnly(predeployProperties,false) && persistenceUnitInfo != null && persistenceUnitInfo.getTransactionType() == PersistenceUnitTransactionType.JTA) {
      if (predeployProperties.get(PersistenceUnitProperties.JTA_DATASOURCE) == null && persistenceUnitInfo.getJtaDataSource() == null) {
        throw new PersistenceException(EntityManagerSetupException.jtaPersistenceUnitInfoMissingJtaDataSource(persistenceUnitInfo.getPersistenceUnitName()));
      }
    }
    if (state == STATE_INITIAL || state == STATE_UNDEPLOYED) {
      enableWeaving=true;
      isWeavingStatic=false;
      String weaving=getConfigPropertyAsString(PersistenceUnitProperties.WEAVING);
      if (weaving != null && weaving.equalsIgnoreCase("String_Node_Str")) {
        enableWeaving=false;
      }
 else       if (weaving != null && weaving.equalsIgnoreCase("String_Node_Str")) {
        isWeavingStatic=true;
      }
    }
    boolean throwExceptionOnFail="String_Node_Str".equalsIgnoreCase(EntityManagerFactoryProvider.getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.TOPLINK_ORM_THROW_EXCEPTIONS,predeployProperties,"String_Node_Str",session));
    ClassTransformer transformer=null;
    if (!isSessionLoadedFromSessionsXML) {
      processor=new MetadataProcessor(persistenceUnitInfo,session,privateClassLoader,enableWeaving);
      PersistenceUnitProcessor.processORMetadata(processor,privateClassLoader,session,throwExceptionOnFail);
      session.getProject().getLogin().setConnector(new DefaultConnector());
      if (session.getIntegrityChecker().hasErrors()) {
        session.handleException(new IntegrityException(session.getIntegrityChecker()));
      }
      if (enableWeaving) {
        boolean weaveChangeTracking="String_Node_Str".equalsIgnoreCase(EntityManagerFactoryProvider.getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.WEAVING_CHANGE_TRACKING,predeployProperties,"String_Node_Str",session));
        boolean weaveLazy="String_Node_Str".equalsIgnoreCase(EntityManagerFactoryProvider.getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.WEAVING_LAZY,predeployProperties,"String_Node_Str",session));
        boolean weaveFetchGroups="String_Node_Str".equalsIgnoreCase(EntityManagerFactoryProvider.getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.WEAVING_FETCHGROUPS,predeployProperties,"String_Node_Str",session));
        Collection entities=PersistenceUnitProcessor.buildEntityList(processor,privateClassLoader);
        transformer=TransformerFactory.createTransformerAndModifyProject(session,entities,privateClassLoader,weaveLazy,weaveChangeTracking,weaveFetchGroups);
      }
    }
 else {
      if (enableWeaving) {
        boolean weaveChangeTracking="String_Node_Str".equalsIgnoreCase(EntityManagerFactoryProvider.getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.WEAVING_CHANGE_TRACKING,predeployProperties,"String_Node_Str",session));
        boolean weaveLazy="String_Node_Str".equalsIgnoreCase(EntityManagerFactoryProvider.getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.WEAVING_LAZY,predeployProperties,"String_Node_Str",session));
        boolean weaveFetchGroups="String_Node_Str".equalsIgnoreCase(EntityManagerFactoryProvider.getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.WEAVING_FETCHGROUPS,predeployProperties,"String_Node_Str",session));
        Collection persistenceClasses=new ArrayList(session.getProject().getDescriptors().keySet());
        transformer=TransformerFactory.createTransformerAndModifyProject(session,persistenceClasses,privateClassLoader,weaveLazy,weaveChangeTracking,weaveFetchGroups);
      }
    }
    if (state != STATE_INITIAL || this.isInContainerMode()) {
      factoryCount++;
    }
    state=STATE_PREDEPLOYED;
    session.log(SessionLog.FINEST,SessionLog.PROPERTIES,"String_Node_Str",new Object[]{getPersistenceUnitInfo().getPersistenceUnitName(),state,factoryCount});
    if (isWeavingStatic) {
      return null;
    }
 else {
      return transformer;
    }
  }
 catch (  RuntimeException ex) {
    state=STATE_PREDEPLOY_FAILED;
    session=null;
    throw new PersistenceException(EntityManagerSetupException.predeployFailed(persistenceUnitInfo.getPersistenceUnitName(),ex));
  }
}