Program: 176855
Project: 176855
Buggy source:
/** 
 * Switch over persistence units.
 * @param entityPuCol the entity pu col
 * @throws SchemaDisagreementException
 * @throws TimedOutException
 * @throws UnavailableException
 * @throws InvalidRequestException
 * @throws TException
 * @throws IOException
 */
protected void switchPersistenceUnits(Map<Class,String> entityPuCol) throws IOException, TException, InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException {
  if (entityPuCol != null) {
    Iterator<Class> iter=entityPuCol.keySet().iterator();
    log.warn("String_Node_Str");
    while (iter.hasNext()) {
      Class clazz=iter.next();
      String pu=entityPuCol.get(clazz);
      Map<String,Metamodel> metaModels=KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodelMap();
      EntityMetadata mAdd=null;
      for (      Metamodel m : metaModels.values()) {
        mAdd=((MetamodelImpl)m).getEntityMetadataMap().get(clazz);
        if (mAdd != null) {
          break;
        }
      }
      mAdd.setPersistenceUnit(pu);
      PersistenceUnitMetadata puMetadata=KunderaMetadata.INSTANCE.getApplicationMetadata().getPersistenceUnitMetadata(pu);
      String client=puMetadata.getProperties().getProperty(PersistenceProperties.KUNDERA_CLIENT_FACTORY);
      if (client.equalsIgnoreCase("String_Node_Str")) {
        if (RUN_IN_EMBEDDED_MODE) {
          CassandraCli.cassandraSetUp();
          CassandraCli.initClient();
        }
        if (AUTO_MANAGE_SCHEMA) {
          if (mAdd.getTableName().equalsIgnoreCase("String_Node_Str")) {
            loadDataForHABITAT();
          }
 else           if (mAdd.getTableName().equalsIgnoreCase("String_Node_Str")) {
            loadDataForPERSONNEL();
          }
        }
      }
 else       if (client.equalsIgnoreCase("String_Node_Str")) {
        if (RUN_IN_EMBEDDED_MODE) {
          HBaseCli.createTable("String_Node_Str");
          HBaseCli.addColumnFamily("String_Node_Str","String_Node_Str");
          HBaseCli.addColumnFamily("String_Node_Str","String_Node_Str");
          HBaseCli.createTable("String_Node_Str");
          HBaseCli.addColumnFamily("String_Node_Str","String_Node_Str");
          HBaseCli.addColumnFamily("String_Node_Str","String_Node_Str");
          HBaseCli.createTable("String_Node_Str");
          HBaseCli.addColumnFamily("String_Node_Str","String_Node_Str");
          HBaseCli.addColumnFamily("String_Node_Str","String_Node_Str");
          HBaseCli.addColumnFamily("String_Node_Str","String_Node_Str");
        }
      }
      String schema=puMetadata.getProperty(PersistenceProperties.KUNDERA_KEYSPACE);
      mAdd.setSchema(schema != null ? schema : "String_Node_Str");
      log.warn("String_Node_Str" + pu + "String_Node_Str"+ clazz.getCanonicalName());
    }
  }
  dao.closeEntityManager();
  em=dao.getEntityManager(persistenceUnits);
}

Fixed version (ground truth):
/** 
 * Switch over persistence units.
 * @param entityPuCol the entity pu col
 * @throws SchemaDisagreementException
 * @throws TimedOutException
 * @throws UnavailableException
 * @throws InvalidRequestException
 * @throws TException
 * @throws IOException
 */
protected void switchPersistenceUnits(Map<Class,String> entityPuCol) throws IOException, TException, InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException {
  if (entityPuCol != null) {
    Iterator<Class> iter=entityPuCol.keySet().iterator();
    log.warn("String_Node_Str");
    while (iter.hasNext()) {
      Class clazz=iter.next();
      String pu=entityPuCol.get(clazz);
      Map<String,Metamodel> metaModels=KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodelMap();
      EntityMetadata mAdd=null;
      for (      Metamodel m : metaModels.values()) {
        mAdd=((MetamodelImpl)m).getEntityMetadataMap().get(clazz);
        if (mAdd != null) {
          break;
        }
      }
      mAdd.setPersistenceUnit(pu);
      PersistenceUnitMetadata puMetadata=KunderaMetadata.INSTANCE.getApplicationMetadata().getPersistenceUnitMetadata(pu);
      String client=puMetadata.getProperties().getProperty(PersistenceProperties.KUNDERA_CLIENT_FACTORY);
      if (client.equalsIgnoreCase("String_Node_Str")) {
        if (RUN_IN_EMBEDDED_MODE) {
          CassandraCli.cassandraSetUp();
          CassandraCli.initClient();
        }
        if (AUTO_MANAGE_SCHEMA) {
          if (mAdd.getTableName().equalsIgnoreCase("String_Node_Str")) {
            loadDataForHABITAT();
          }
 else           if (mAdd.getTableName().equalsIgnoreCase("String_Node_Str")) {
            loadDataForPERSONNEL();
          }
        }
      }
 else       if (client.equalsIgnoreCase("String_Node_Str")) {
        if (!RUN_IN_EMBEDDED_MODE) {
          HBaseCli.createTable("String_Node_Str");
          HBaseCli.addColumnFamily("String_Node_Str","String_Node_Str");
          HBaseCli.addColumnFamily("String_Node_Str","String_Node_Str");
          HBaseCli.createTable("String_Node_Str");
          HBaseCli.addColumnFamily("String_Node_Str","String_Node_Str");
          HBaseCli.addColumnFamily("String_Node_Str","String_Node_Str");
          HBaseCli.createTable("String_Node_Str");
          HBaseCli.addColumnFamily("String_Node_Str","String_Node_Str");
          HBaseCli.addColumnFamily("String_Node_Str","String_Node_Str");
          HBaseCli.addColumnFamily("String_Node_Str","String_Node_Str");
        }
      }
      String schema=puMetadata.getProperty(PersistenceProperties.KUNDERA_KEYSPACE);
      mAdd.setSchema(schema != null ? schema : "String_Node_Str");
      log.warn("String_Node_Str" + pu + "String_Node_Str"+ clazz.getCanonicalName());
    }
  }
  dao.closeEntityManager();
  em=dao.getEntityManager(persistenceUnits);
}