Program: 113054
Project: 113054
Buggy source:
@Override public boolean delete(final QueryOptions queryOptions,final Query query){
  if (((query == null) || (query instanceof EverythingQuery)) && queryOptions.isAllAdapters()) {
    try {
      operations.deleteAll();
      return true;
    }
 catch (    final IOException e) {
      LOGGER.error("String_Node_Str",e);
      return false;
    }
  }
  final AtomicBoolean aOk=new AtomicBoolean(true);
  final Set<ByteArrayId> queriedAdapters=new HashSet<ByteArrayId>();
  try {
    for (    final Pair<PrimaryIndex,List<DataAdapter<Object>>> indexAdapterPair : queryOptions.getIndicesForAdapters(adapterStore,indexMappingStore,indexStore)) {
      final PrimaryIndex index=indexAdapterPair.getLeft();
      final String tableName=StringUtils.stringFromBinary(index.getId().getBytes());
      final String altIdxTableName=tableName + HBaseUtils.ALT_INDEX_TABLE;
      final boolean useAltIndex=options.isUseAltIndex() && operations.tableExists(altIdxTableName);
      final HBaseWriter idxDeleter=operations.createWriter(tableName,"String_Node_Str",false);
      final HBaseWriter altIdxDelete=useAltIndex ? operations.createWriter(altIdxTableName,"String_Node_Str",false) : null;
      for (      final DataAdapter<Object> adapter : indexAdapterPair.getRight()) {
        final DataStoreCallbackManager callbackCache=new DataStoreCallbackManager(statisticsStore,secondaryIndexDataStore,queriedAdapters.add(adapter.getAdapterId()));
        callbackCache.setPersistStats(options.persistDataStatistics);
        if (query instanceof EverythingQuery) {
          deleteEntries(adapter,index,queryOptions.getAuthorizations());
          continue;
        }
        final ScanCallback<Object> callback=new ScanCallback<Object>(){
          @Override public void entryScanned(          final DataStoreEntryInfo entryInfo,          final Object entry){
            callbackCache.getDeleteCallback((WritableDataAdapter<Object>)adapter,index).entryDeleted(entryInfo,entry);
            try {
              addToBatch(idxDeleter,entryInfo.getRowIds());
              if (altIdxDelete != null) {
                addToBatch(altIdxDelete,Collections.singletonList(adapter.getDataId(entry)));
              }
            }
 catch (            final IOException e) {
              LOGGER.error("String_Node_Str",e);
              aOk.set(false);
            }
          }
        }
;
        CloseableIterator<?> dataIt=null;
        if (query instanceof RowIdQuery) {
          final HBaseRowIdsQuery<Object> q=new HBaseRowIdsQuery<Object>(adapter,index,((RowIdQuery)query).getRowIds(),callback,null,queryOptions.getAuthorizations());
          dataIt=q.query(operations,adapterStore,-1);
        }
 else         if (query instanceof DataIdQuery) {
          final DataIdQuery idQuery=(DataIdQuery)query;
          dataIt=getEntries(index,idQuery.getDataIds(),adapter,null,callback,queryOptions.getAuthorizations(),null,false);
        }
 else         if (query instanceof PrefixIdQuery) {
        }
 else {
          dataIt=new HBaseConstraintsQuery(Collections.singletonList(adapter.getAdapterId()),index,query,null,callback,null,queryOptions.getAuthorizations()).query(operations,adapterStore,null);
        }
        while (dataIt.hasNext()) {
          dataIt.next();
        }
        try {
          dataIt.close();
        }
 catch (        final Exception ex) {
          LOGGER.warn("String_Node_Str",ex);
        }
        callbackCache.close();
      }
      if (altIdxDelete != null) {
        altIdxDelete.close();
      }
      idxDeleter.close();
    }
    return aOk.get();
  }
 catch (  final IOException e) {
    LOGGER.error("String_Node_Str" + query.toString(),e);
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean delete(final QueryOptions queryOptions,final Query query){
  if (((query == null) || (query instanceof EverythingQuery)) && queryOptions.isAllAdapters()) {
    try {
      operations.deleteAll();
      return true;
    }
 catch (    final IOException e) {
      LOGGER.error("String_Node_Str",e);
      return false;
    }
  }
  final AtomicBoolean aOk=new AtomicBoolean(true);
  final Set<ByteArrayId> queriedAdapters=new HashSet<ByteArrayId>();
  try {
    for (    final Pair<PrimaryIndex,List<DataAdapter<Object>>> indexAdapterPair : queryOptions.getIndicesForAdapters(adapterStore,indexMappingStore,indexStore)) {
      final PrimaryIndex index=indexAdapterPair.getLeft();
      final String tableName=StringUtils.stringFromBinary(index.getId().getBytes());
      final String altIdxTableName=tableName + HBaseUtils.ALT_INDEX_TABLE;
      final boolean useAltIndex=options.isUseAltIndex() && operations.tableExists(altIdxTableName);
      final HBaseWriter idxDeleter=operations.createWriter(tableName,"String_Node_Str",false);
      final HBaseWriter altIdxDelete=useAltIndex ? operations.createWriter(altIdxTableName,"String_Node_Str",false) : null;
      for (      final DataAdapter<Object> adapter : indexAdapterPair.getRight()) {
        final DataStoreCallbackManager callbackCache=new DataStoreCallbackManager(statisticsStore,secondaryIndexDataStore,queriedAdapters.add(adapter.getAdapterId()));
        callbackCache.setPersistStats(options.persistDataStatistics);
        if (query instanceof EverythingQuery) {
          deleteEntries(adapter,index,queryOptions.getAuthorizations());
          continue;
        }
        final ScanCallback<Object> callback=new ScanCallback<Object>(){
          @Override public void entryScanned(          final DataStoreEntryInfo entryInfo,          final Object entry){
            callbackCache.getDeleteCallback((WritableDataAdapter<Object>)adapter,index).entryDeleted(entryInfo,entry);
            try {
              addToBatch(idxDeleter,entryInfo.getRowIds());
              if (altIdxDelete != null) {
                addToBatch(altIdxDelete,Collections.singletonList(adapter.getDataId(entry)));
              }
            }
 catch (            final IOException e) {
              LOGGER.error("String_Node_Str",e);
              aOk.set(false);
            }
          }
        }
;
        CloseableIterator<?> dataIt=null;
        if (query instanceof RowIdQuery) {
          final HBaseRowIdsQuery<Object> q=new HBaseRowIdsQuery<Object>(adapter,index,((RowIdQuery)query).getRowIds(),callback,null,queryOptions.getAuthorizations());
          dataIt=q.query(operations,adapterStore,-1);
        }
 else         if (query instanceof DataIdQuery) {
          final DataIdQuery idQuery=(DataIdQuery)query;
          dataIt=getEntries(index,idQuery.getDataIds(),adapter,null,callback,queryOptions.getAuthorizations(),null,false);
        }
 else         if (query instanceof PrefixIdQuery) {
        }
 else {
          dataIt=new HBaseConstraintsQuery(Collections.singletonList(adapter.getAdapterId()),index,query,null,callback,null,queryOptions.getAuthorizations()).query(operations,adapterStore,null);
        }
        if (dataIt != null) {
          while (dataIt.hasNext()) {
            dataIt.next();
          }
          try {
            dataIt.close();
          }
 catch (          final Exception ex) {
            LOGGER.warn("String_Node_Str",ex);
          }
        }
        callbackCache.close();
      }
      if (altIdxDelete != null) {
        altIdxDelete.close();
      }
      idxDeleter.close();
    }
    return aOk.get();
  }
 catch (  final IOException e) {
    LOGGER.error("String_Node_Str" + query.toString(),e);
    return false;
  }
}