Program: 176662
Project: 176662
Buggy source:
/** 
 * Execute batch.
 * @return the int
 */
public int executeBatch(){
  String persistenceUnit=null;
  Cassandra.Client conn=null;
  Object pooledConnection=null;
  Map<ByteBuffer,Map<String,List<Mutation>>> mutationMap=new HashMap<ByteBuffer,Map<String,List<Mutation>>>();
  try {
    for (    Node node : nodes) {
      if (node.isDirty()) {
        Object entity=node.getData();
        Object id=node.getEntityId();
        EntityMetadata metadata=KunderaMetadataManager.getEntityMetadata(node.getDataClass());
        persistenceUnit=metadata.getPersistenceUnit();
        isUpdate=node.isUpdate();
        MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(metadata.getPersistenceUnit());
        if (node.isInState(RemovedState.class)) {
          delete(entity,id);
        }
 else         if (metaModel.isEmbeddable(metadata.getIdAttribute().getBindableJavaType())) {
          List<RelationHolder> relationHolders=getRelationHolders(node);
          onPersist(metadata,entity,id,relationHolders);
        }
 else {
          List<RelationHolder> relationHolders=getRelationHolders(node);
          mutationMap=prepareMutation(metadata,entity,id,relationHolders,mutationMap);
          indexNode(node,metadata);
        }
      }
    }
    if (!mutationMap.isEmpty()) {
      pooledConnection=getPooledConection(persistenceUnit);
      conn=getConnection(pooledConnection);
      conn.batch_mutate(mutationMap,consistencyLevel);
    }
  }
 catch (  InvalidRequestException e) {
    log.error("String_Node_Str" + e);
    throw new KunderaException(e);
  }
catch (  TException e) {
    log.error("String_Node_Str" + e);
    throw new KunderaException(e);
  }
catch (  UnavailableException e) {
    log.error("String_Node_Str" + e);
    throw new KunderaException(e);
  }
catch (  TimedOutException e) {
    log.error("String_Node_Str" + e);
    throw new KunderaException(e);
  }
 finally {
    clear();
    releaseConnection(pooledConnection);
  }
  return mutationMap.size();
}

Fixed version (ground truth):
/** 
 * Execute batch.
 * @return the int
 */
public int executeBatch(){
  String persistenceUnit=null;
  Cassandra.Client conn=null;
  Object pooledConnection=null;
  Map<Class<?>,Map<ByteBuffer,Map<String,List<Mutation>>>> batchMutationMap=new HashMap<Class<?>,Map<ByteBuffer,Map<String,List<Mutation>>>>();
  int recordsExecuted=0;
  try {
    for (    Node node : nodes) {
      if (node.isDirty()) {
        Object entity=node.getData();
        Object id=node.getEntityId();
        EntityMetadata metadata=KunderaMetadataManager.getEntityMetadata(node.getDataClass());
        persistenceUnit=metadata.getPersistenceUnit();
        isUpdate=node.isUpdate();
        MetamodelImpl metaModel=(MetamodelImpl)KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(metadata.getPersistenceUnit());
        if (node.isInState(RemovedState.class)) {
          delete(entity,id);
        }
 else         if (metaModel.isEmbeddable(metadata.getIdAttribute().getBindableJavaType())) {
          List<RelationHolder> relationHolders=getRelationHolders(node);
          onPersist(metadata,entity,id,relationHolders);
        }
 else {
          List<RelationHolder> relationHolders=getRelationHolders(node);
          Map<ByteBuffer,Map<String,List<Mutation>>> mutationMap=new HashMap<ByteBuffer,Map<String,List<Mutation>>>();
          mutationMap=prepareMutation(metadata,entity,id,relationHolders,mutationMap);
          recordsExecuted+=mutationMap.size();
          if (!batchMutationMap.containsKey(metadata.getEntityClazz())) {
            batchMutationMap.put(metadata.getEntityClazz(),mutationMap);
          }
 else {
            batchMutationMap.get(metadata.getEntityClazz()).putAll(mutationMap);
          }
          indexNode(node,metadata);
        }
      }
    }
    if (!batchMutationMap.isEmpty()) {
      pooledConnection=getPooledConection(persistenceUnit);
      conn=getConnection(pooledConnection);
      for (      Class<?> entityClass : batchMutationMap.keySet()) {
        conn.batch_mutate(batchMutationMap.get(entityClass),consistencyLevel);
      }
    }
  }
 catch (  InvalidRequestException e) {
    log.error("String_Node_Str" + e);
    throw new KunderaException(e);
  }
catch (  TException e) {
    log.error("String_Node_Str" + e);
    throw new KunderaException(e);
  }
catch (  UnavailableException e) {
    log.error("String_Node_Str" + e);
    throw new KunderaException(e);
  }
catch (  TimedOutException e) {
    log.error("String_Node_Str" + e);
    throw new KunderaException(e);
  }
 finally {
    clear();
    releaseConnection(pooledConnection);
  }
  return recordsExecuted;
}