nus-yam/ex-repair huggingface dataset:
Program: 82146
Project: 82146
Buggy source:
@Override public void bulkMutateFinish(String bulkId,boolean apply,boolean blockUntilComplete) throws BlurException, TException {
  try {
    List<String> tableListByCluster=tableListByCluster(_cluster);
    _indexManager.bulkMutateFinish(new HashSet<String>(tableListByCluster),bulkId,apply,blockUntilComplete);
  }
 catch (  Exception e) {
    LOG.error("String_Node_Str" + bulkId + "String_Node_Str",e);
    if (e instanceof BlurException) {
      throw (BlurException)e;
    }
    throw new BException(e.getMessage(),e);
  }
}

Fixed version (ground truth):
@Override public void bulkMutateFinish(String bulkId,boolean apply,boolean blockUntilComplete) throws BlurException, TException {
  try {
    List<String> tableListByCluster=tableListByCluster(_cluster);
    List<String> writableTables=new ArrayList<String>();
    for (    String table : tableListByCluster) {
      if (_clusterStatus.isReadOnly(true,_cluster,table)) {
        writableTables.add(table);
      }
    }
    _indexManager.bulkMutateFinish(new HashSet<String>(writableTables),bulkId,apply,blockUntilComplete);
  }
 catch (  Exception e) {
    LOG.error("String_Node_Str" + bulkId + "String_Node_Str",e);
    if (e instanceof BlurException) {
      throw (BlurException)e;
    }
    throw new BException(e.getMessage(),e);
  }
}
Program: 82147
Project: 82147
Buggy source:
@Override public IndexOutput createOutput(final String name,IOContext context) throws IOException {
  LOG.debug("String_Node_Str",name,context,getPath());
  if (fileExists(name)) {
    deleteFile(name);
  }
  _fileStatusMap.put(name,new FStat(System.currentTimeMillis(),0L));
  final FSDataOutputStream outputStream=openForOutput(name);
  return new BufferedIndexOutput(){
    @Override public long length() throws IOException {
      return outputStream.getPos();
    }
    @Override protected void flushBuffer(    byte[] b,    int offset,    int len) throws IOException {
      long start=System.nanoTime();
      outputStream.write(b,offset,len);
      long end=System.nanoTime();
      _metricsGroup.writeAccess.update((end - start) / 1000);
      _metricsGroup.writeThroughput.mark(len);
    }
    @Override public void close() throws IOException {
      super.close();
      _fileStatusMap.put(name,new FStat(System.currentTimeMillis(),outputStream.getPos()));
      if (_asyncClosing) {
        outputStream.sync();
        CLOSING_QUEUE.add(outputStream);
      }
 else {
        outputStream.close();
      }
      openForInput(name);
    }
    @Override public void seek(    long pos) throws IOException {
      throw new IOException("String_Node_Str");
    }
  }
;
}

Fixed version (ground truth):
@Override public IndexOutput createOutput(final String name,IOContext context) throws IOException {
  LOG.debug("String_Node_Str",name,context,getPath());
  if (fileExists(name)) {
    deleteFile(name);
  }
  if (_useCache) {
    _fileStatusMap.put(name,new FStat(System.currentTimeMillis(),0L));
  }
  final FSDataOutputStream outputStream=openForOutput(name);
  return new BufferedIndexOutput(){
    @Override public long length() throws IOException {
      return outputStream.getPos();
    }
    @Override protected void flushBuffer(    byte[] b,    int offset,    int len) throws IOException {
      long start=System.nanoTime();
      outputStream.write(b,offset,len);
      long end=System.nanoTime();
      _metricsGroup.writeAccess.update((end - start) / 1000);
      _metricsGroup.writeThroughput.mark(len);
    }
    @Override public void close() throws IOException {
      super.close();
      if (_useCache) {
        _fileStatusMap.put(name,new FStat(System.currentTimeMillis(),outputStream.getPos()));
      }
      if (_asyncClosing && _useCache) {
        outputStream.sync();
        CLOSING_QUEUE.add(outputStream);
      }
 else {
        outputStream.close();
      }
      openForInput(name);
    }
    @Override public void seek(    long pos) throws IOException {
      throw new IOException("String_Node_Str");
    }
  }
;
}
Program: 82148
Project: 82148
Buggy source:
public FastHdfsKeyValueDirectory(Timer hdfsKeyValueTimer,Configuration configuration,Path path) throws IOException {
  _path=path;
  _store=new HdfsKeyValueStore(hdfsKeyValueTimer,configuration,path);
  MemoryLeakDetector.record(_store,"String_Node_Str",path.toString());
  BytesRef value=new BytesRef();
  if (_store.get(FILES,value)) {
    String filesString=value.utf8ToString();
    String[] files=filesString.split("String_Node_Str" + SEP);
    for (    String file : files) {
      if (file.isEmpty()) {
        throw new IOException("String_Node_Str" + filesString + "String_Node_Str");
      }
      BytesRef key=new BytesRef(file + LENGTH);
      if (_store.get(key,value)) {
        _files.put(file,Long.parseLong(value.utf8ToString()));
      }
 else {
        LOG.warn(MISSING_METADATA_MESSAGE,file);
      }
    }
  }
  setLockFactory(NoLockFactory.getNoLockFactory());
  writeFilesNames();
  gc();
}

Fixed version (ground truth):
public FastHdfsKeyValueDirectory(Timer hdfsKeyValueTimer,Configuration configuration,Path path,long maxAmountAllowedPerFile,long maxOpenForWriting) throws IOException {
  _path=path;
  _store=new HdfsKeyValueStore(hdfsKeyValueTimer,configuration,path,maxAmountAllowedPerFile,maxOpenForWriting);
  MemoryLeakDetector.record(_store,"String_Node_Str",path.toString());
  BytesRef value=new BytesRef();
  if (_store.get(FILES,value)) {
    String filesString=value.utf8ToString();
    if (!filesString.isEmpty()) {
      String[] files=filesString.split("String_Node_Str" + SEP);
      for (      String file : files) {
        if (file.isEmpty()) {
          throw new IOException("String_Node_Str" + filesString + "String_Node_Str");
        }
        BytesRef key=new BytesRef(file + LENGTH);
        if (_store.get(key,value)) {
          _files.put(file,Long.parseLong(value.utf8ToString()));
        }
 else {
          LOG.warn(MISSING_METADATA_MESSAGE,file);
        }
      }
    }
  }
  setLockFactory(NoLockFactory.getNoLockFactory());
  writeFileNamesAndSync();
  gc();
}
Program: 82149
Project: 82149
Buggy source:
public HdfsKeyValueStore(Timer hdfsKeyValueTimer,Configuration configuration,Path path,long maxAmountAllowedPerFile) throws IOException {
  _maxAmountAllowedPerFile=maxAmountAllowedPerFile;
  _path=path;
  _fileSystem=_path.getFileSystem(configuration);
  _fileSystem.mkdirs(_path);
  _readWriteLock=new ReentrantReadWriteLock();
  _writeLock=_readWriteLock.writeLock();
  _readLock=_readWriteLock.readLock();
  _fileStatus.set(getSortedSet(_path));
  if (!_fileStatus.get().isEmpty()) {
    _currentFileCounter.set(Long.parseLong(_fileStatus.get().last().getPath().getName()));
  }
  removeAnyTruncatedFiles();
  loadIndexes();
  cleanupOldFiles();
  _idleLogTimerTask=getIdleLogTimer();
  _oldFileCleanerTimerTask=getOldFileCleanerTimer();
  _hdfsKeyValueTimer=hdfsKeyValueTimer;
  _hdfsKeyValueTimer.schedule(_idleLogTimerTask,DAEMON_POLL_TIME,DAEMON_POLL_TIME);
  _hdfsKeyValueTimer.schedule(_oldFileCleanerTimerTask,DAEMON_POLL_TIME,DAEMON_POLL_TIME);
}

Fixed version (ground truth):
public HdfsKeyValueStore(Timer hdfsKeyValueTimer,Configuration configuration,Path path,long maxAmountAllowedPerFile,long maxOpenForWriting) throws IOException {
  _maxOpenForWriting=maxOpenForWriting;
  _maxAmountAllowedPerFile=maxAmountAllowedPerFile;
  _path=path;
  _fileSystem=_path.getFileSystem(configuration);
  _fileSystem.mkdirs(_path);
  _readWriteLock=new ReentrantReadWriteLock();
  _writeLock=_readWriteLock.writeLock();
  _readLock=_readWriteLock.readLock();
  _fileStatus.set(getSortedSet(_path));
  if (!_fileStatus.get().isEmpty()) {
    _currentFileCounter.set(Long.parseLong(_fileStatus.get().last().getPath().getName()));
  }
  removeAnyTruncatedFiles();
  loadIndexes();
  cleanupOldFiles();
  _idleLogTimerTask=getIdleLogTimer();
  _oldFileCleanerTimerTask=getOldFileCleanerTimer();
  _hdfsKeyValueTimer=hdfsKeyValueTimer;
  _hdfsKeyValueTimer.schedule(_idleLogTimerTask,DAEMON_POLL_TIME,DAEMON_POLL_TIME);
  _hdfsKeyValueTimer.schedule(_oldFileCleanerTimerTask,DAEMON_POLL_TIME,DAEMON_POLL_TIME);
}
Program: 82150
Project: 82150
Buggy source:
private void closeLogFileIfIdle() throws IOException {
  _writeLock.lock();
  try {
    if (_output != null && _lastWrite.get() + MAX_OPEN_FOR_WRITING < System.currentTimeMillis()) {
      LOG.info("String_Node_Str",_path);
      try {
        _output.close();
      }
  finally {
        _output=null;
      }
    }
  }
  finally {
    _writeLock.unlock();
  }
}

Fixed version (ground truth):
private void closeLogFileIfIdle() throws IOException {
  _writeLock.lock();
  try {
    if (_output != null && _lastWrite.get() + _maxOpenForWriting < System.currentTimeMillis()) {
      LOG.info("String_Node_Str",_path);
      try {
        _output.close();
      }
  finally {
        _output=null;
      }
    }
  }
  finally {
    _writeLock.unlock();
  }
}
Program: 82151
Project: 82151
Buggy source:
public BlurQueryParser(Version matchVersion,String f,Map<Query,String> fieldNames,FieldManager fieldManager){
  super(matchVersion,f,fieldManager.getAnalyzerForQuery());
  _fieldNames=fieldNames == null ? new HashMap<Query,String>() : fieldNames;
  _fieldManager=fieldManager;
  setAllowLeadingWildcard(true);
}

Fixed version (ground truth):
public BlurQueryParser(Version matchVersion,String f,Map<Query,String> fieldNames,FieldManager fieldManager){
  super(matchVersion,f,fieldManager.getAnalyzerForQuery());
  _fieldNames=fieldNames == null ? new HashMap<Query,String>() : fieldNames;
  _fieldManager=fieldManager;
  setAllowLeadingWildcard(true);
  setAutoGeneratePhraseQueries(true);
}
Program: 82152
Project: 82152
Buggy source:
public <K extends TBase<?,?>>ThriftCacheKey<K> getKey(String table,K tkey,Class<K> clazz){
  User user=UserContext.getUser();
  return new ThriftCacheKey<K>(user,table,tkey,clazz);
}

Fixed version (ground truth):
public <K extends TBase<?,?>>ThriftCacheKey<K> getKey(String table,int[] shards,K tkey,Class<K> clazz) throws BlurException {
  User user=UserContext.getUser();
  return new ThriftCacheKey<K>(user,table,shards,tkey,clazz);
}
Program: 82153
Project: 82153
Buggy source:
@Override public int weightOf(ThriftCacheValue<?> value){
  return value.size();
}

Fixed version (ground truth):
@Override public int weightOf(ThriftCacheKey<?> key,ThriftCacheValue<?> value){
  return key.size() + value.size();
}
Program: 82154
Project: 82154
Buggy source:
public ThriftCache(long totalNumberOfBytes){
  _hits=Metrics.newMeter(new MetricName(ORG_APACHE_BLUR,THRIFT_CACHE,HIT),HIT,TimeUnit.SECONDS);
  _misses=Metrics.newMeter(new MetricName(ORG_APACHE_BLUR,THRIFT_CACHE,MISS),MISS,TimeUnit.SECONDS);
  _evictions=Metrics.newMeter(new MetricName(ORG_APACHE_BLUR,THRIFT_CACHE,EVICTION),EVICTION,TimeUnit.SECONDS);
  _cacheMap=new ConcurrentLinkedHashMap.Builder<ThriftCacheKey<?>,ThriftCacheValue<?>>().weigher(new Weigher<ThriftCacheValue<?>>(){
    @Override public int weightOf(    ThriftCacheValue<?> value){
      return value.size();
    }
  }
).listener(new EvictionListener<ThriftCacheKey<?>,ThriftCacheValue<?>>(){
    @Override public void onEviction(    ThriftCacheKey<?> key,    ThriftCacheValue<?> value){
      _evictions.mark();
      _evictionsAtomicLong.incrementAndGet();
    }
  }
).maximumWeightedCapacity(totalNumberOfBytes).build();
  _hitsAtomicLong=new AtomicLong();
  _missesAtomicLong=new AtomicLong();
  _evictionsAtomicLong=new AtomicLong();
}

Fixed version (ground truth):
public ThriftCache(long totalNumberOfBytes){
  _hits=Metrics.newMeter(new MetricName(ORG_APACHE_BLUR,THRIFT_CACHE,HIT),HIT,TimeUnit.SECONDS);
  _misses=Metrics.newMeter(new MetricName(ORG_APACHE_BLUR,THRIFT_CACHE,MISS),MISS,TimeUnit.SECONDS);
  _evictions=Metrics.newMeter(new MetricName(ORG_APACHE_BLUR,THRIFT_CACHE,EVICTION),EVICTION,TimeUnit.SECONDS);
  _cacheMap=new ConcurrentLinkedHashMap.Builder<ThriftCacheKey<?>,ThriftCacheValue<?>>().weigher(new EntryWeigher<ThriftCacheKey<?>,ThriftCacheValue<?>>(){
    @Override public int weightOf(    ThriftCacheKey<?> key,    ThriftCacheValue<?> value){
      return key.size() + value.size();
    }
  }
).listener(new EvictionListener<ThriftCacheKey<?>,ThriftCacheValue<?>>(){
    @Override public void onEviction(    ThriftCacheKey<?> key,    ThriftCacheValue<?> value){
      _evictions.mark();
      _evictionsAtomicLong.incrementAndGet();
    }
  }
).maximumWeightedCapacity(totalNumberOfBytes).build();
  _hitsAtomicLong=new AtomicLong();
  _missesAtomicLong=new AtomicLong();
  _evictionsAtomicLong=new AtomicLong();
}
Program: 82155
Project: 82155
Buggy source:
public <K extends TBase<?,?>,V extends TBase<?,?>>V put(ThriftCacheKey<K> key,V t) throws BlurException {
  _cacheMap.put(key,new ThriftCacheValue<V>(t));
  return t;
}

Fixed version (ground truth):
public <K extends TBase<?,?>,V extends TBase<?,?>>V put(ThriftCacheKey<K> key,V t) throws BlurException {
synchronized (_lastModTimestamps) {
    Long lastModTimestamp=_lastModTimestamps.get(key.getTable());
    if (lastModTimestamp != null && key.getTimestamp() < lastModTimestamp) {
      return t;
    }
  }
  LOG.debug("String_Node_Str",t,key);
  _cacheMap.put(key,new ThriftCacheValue<V>(t));
  return t;
}
Program: 82156
Project: 82156
Buggy source:
public void clearTable(String table){
  LOG.info("String_Node_Str",table);
  Set<Entry<ThriftCacheKey<?>,ThriftCacheValue<?>>> entrySet=_cacheMap.entrySet();
  Iterator<Entry<ThriftCacheKey<?>,ThriftCacheValue<?>>> iterator=entrySet.iterator();
  while (iterator.hasNext()) {
    Entry<ThriftCacheKey<?>,ThriftCacheValue<?>> entry=iterator.next();
    if (entry.getKey().getTable().equals(table)) {
      iterator.remove();
    }
  }
}

Fixed version (ground truth):
public void clearTable(String table){
synchronized (_lastModTimestamps) {
    _lastModTimestamps.put(table,System.nanoTime());
  }
  LOG.info("String_Node_Str",table);
  Set<Entry<ThriftCacheKey<?>,ThriftCacheValue<?>>> entrySet=_cacheMap.entrySet();
  Iterator<Entry<ThriftCacheKey<?>,ThriftCacheValue<?>>> iterator=entrySet.iterator();
  while (iterator.hasNext()) {
    Entry<ThriftCacheKey<?>,ThriftCacheValue<?>> entry=iterator.next();
    if (entry.getKey().getTable().equals(table)) {
      iterator.remove();
    }
  }
}
Program: 82157
Project: 82157
Buggy source:
public ThriftCacheKey(User user,String table,T t,Class<T> clazz){
  _clazz=clazz.getName();
  if (user != null) {
    _username=user.getUsername();
    Map<String,String> attributes=user.getAttributes();
    if (attributes == null) {
      _attributes=attributes;
    }
 else {
      _attributes=new TreeMap<String,String>(user.getAttributes());
    }
  }
 else {
    _username=null;
    _attributes=null;
  }
  _table=table;
  _t=t;
}

Fixed version (ground truth):
public ThriftCacheKey(User user,String table,int[] shards,T t,Class<T> clazz) throws BlurException {
  _timestamp=System.nanoTime();
  _clazz=new ClassObj<T>(clazz);
  if (user != null) {
    _username=user.getUsername();
    Map<String,String> attributes=user.getAttributes();
    if (attributes == null) {
      _attributes=attributes;
    }
 else {
      _attributes=new TreeMap<String,String>(user.getAttributes());
    }
  }
 else {
    _username=null;
    _attributes=null;
  }
  _table=table;
  _shards=shards;
  _key=new ThriftCacheValue<T>(t);
}
Program: 82158
Project: 82158
Buggy source:
@Override public int hashCode(){
  final int prime=31;
  int result=1;
  result=prime * result + ((_attributes == null) ? 0 : _attributes.hashCode());
  result=prime * result + ((_clazz == null) ? 0 : _clazz.hashCode());
  result=prime * result + ((_t == null) ? 0 : _t.hashCode());
  result=prime * result + ((_table == null) ? 0 : _table.hashCode());
  result=prime * result + ((_username == null) ? 0 : _username.hashCode());
  return result;
}

Fixed version (ground truth):
@Override public int hashCode(){
  final int prime=31;
  int result=1;
  result=prime * result + ((_attributes == null) ? 0 : _attributes.hashCode());
  result=prime * result + ((_clazz == null) ? 0 : _clazz.hashCode());
  result=prime * result + ((_key == null) ? 0 : _key.hashCode());
  result=prime * result + Arrays.hashCode(_shards);
  result=prime * result + ((_table == null) ? 0 : _table.hashCode());
  result=prime * result + ((_username == null) ? 0 : _username.hashCode());
  return result;
}
Program: 82159
Project: 82159
Buggy source:
@Override public boolean equals(Object obj){
  if (this == obj)   return true;
  if (obj == null)   return false;
  if (getClass() != obj.getClass())   return false;
  ThriftCacheKey<?> other=(ThriftCacheKey<?>)obj;
  if (_attributes == null) {
    if (other._attributes != null)     return false;
  }
 else   if (!_attributes.equals(other._attributes))   return false;
  if (_clazz == null) {
    if (other._clazz != null)     return false;
  }
 else   if (!_clazz.equals(other._clazz))   return false;
  if (_t == null) {
    if (other._t != null)     return false;
  }
 else   if (!_t.equals(other._t))   return false;
  if (_table == null) {
    if (other._table != null)     return false;
  }
 else   if (!_table.equals(other._table))   return false;
  if (_username == null) {
    if (other._username != null)     return false;
  }
 else   if (!_username.equals(other._username))   return false;
  return true;
}

Fixed version (ground truth):
@Override public boolean equals(Object obj){
  if (this == obj)   return true;
  if (obj == null)   return false;
  if (getClass() != obj.getClass())   return false;
  ThriftCacheKey<?> other=(ThriftCacheKey<?>)obj;
  if (_attributes == null) {
    if (other._attributes != null)     return false;
  }
 else   if (!_attributes.equals(other._attributes))   return false;
  if (_clazz == null) {
    if (other._clazz != null)     return false;
  }
 else   if (!_clazz.equals(other._clazz))   return false;
  if (_key == null) {
    if (other._key != null)     return false;
  }
 else   if (!_key.equals(other._key))   return false;
  if (!Arrays.equals(_shards,other._shards))   return false;
  if (_table == null) {
    if (other._table != null)     return false;
  }
 else   if (!_table.equals(other._table))   return false;
  if (_username == null) {
    if (other._username != null)     return false;
  }
 else   if (!_username.equals(other._username))   return false;
  return true;
}
Program: 82160
Project: 82160
Buggy source:
@Override public String toString(){
  return "String_Node_Str" + _username + "String_Node_Str"+ _attributes+ "String_Node_Str"+ _table+ "String_Node_Str"+ _t+ "String_Node_Str"+ _clazz+ "String_Node_Str";
}

Fixed version (ground truth):
@Override public String toString(){
  try {
    return "String_Node_Str" + _username + "String_Node_Str"+ _attributes+ "String_Node_Str"+ _table+ "String_Node_Str"+ Arrays.toString(_shards)+ "String_Node_Str"+ _clazz+ "String_Node_Str"+ _key.getValue(_clazz.getClazz())+ "String_Node_Str"+ _timestamp+ "String_Node_Str";
  }
 catch (  BlurException e) {
    throw new RuntimeException(e);
  }
}
Program: 82161
Project: 82161
Buggy source:
@Override public FetchResult fetchRow(String table,Selector selector) throws BlurException, TException {
  Selector copy=new Selector(selector);
  ThriftCacheKey<Selector> key=_thriftCache.getKey(table,copy,Selector.class);
  FetchResult results=_thriftCache.get(key,FetchResult.class);
  if (results != null) {
    return results;
  }
  return _thriftCache.put(key,super.fetchRow(table,selector));
}

Fixed version (ground truth):
@Override public FetchResult fetchRow(String table,Selector selector) throws BlurException, TException {
  Selector copy=new Selector(selector);
  ThriftCacheKey<Selector> key=_thriftCache.getKey(table,getShards(table),copy,Selector.class);
  FetchResult results=_thriftCache.get(key,FetchResult.class);
  if (results != null) {
    return results;
  }
  return _thriftCache.put(key,super.fetchRow(table,selector));
}
Program: 82162
Project: 82162
Buggy source:
public ThriftCacheServer(BlurConfiguration configuration,Iface iface,ThriftCache thriftCache){
  super(configuration,iface,true);
  _thriftCache=thriftCache;
}

Fixed version (ground truth):
public ThriftCacheServer(BlurConfiguration configuration,Iface iface,IndexServer indexServer,ThriftCache thriftCache){
  super(configuration,iface,true);
  _thriftCache=thriftCache;
  _indexServer=indexServer;
}
Program: 82163
Project: 82163
Buggy source:
@Override public BlurResults query(String table,BlurQuery blurQuery) throws BlurException, TException {
  boolean useCacheIfPresent=blurQuery.isUseCacheIfPresent();
  boolean cacheResult=blurQuery.isCacheResult();
  BlurQuery copy=new BlurQuery(blurQuery);
  copy.useCacheIfPresent=false;
  copy.maxQueryTime=0;
  copy.uuid=null;
  copy.userContext=null;
  copy.cacheResult=false;
  copy.startTime=0;
  ThriftCacheKey<BlurQuery> key=_thriftCache.getKey(table,copy,BlurQuery.class);
  BlurResults results=_thriftCache.get(key,BlurResults.class);
  if (results != null && useCacheIfPresent) {
    return results;
  }
  BlurResults blurResults=super.query(table,blurQuery);
  if (cacheResult) {
    return _thriftCache.put(key,blurResults);
  }
  return blurResults;
}

Fixed version (ground truth):
@Override public BlurResults query(String table,BlurQuery blurQuery) throws BlurException, TException {
  boolean useCacheIfPresent=blurQuery.isUseCacheIfPresent();
  boolean cacheResult=blurQuery.isCacheResult();
  BlurQuery copy=new BlurQuery(blurQuery);
  copy.useCacheIfPresent=false;
  copy.maxQueryTime=0;
  copy.uuid=null;
  copy.userContext=null;
  copy.cacheResult=false;
  copy.startTime=0;
  ThriftCacheKey<BlurQuery> key=_thriftCache.getKey(table,getShards(table),copy,BlurQuery.class);
  if (useCacheIfPresent) {
    BlurResults results=_thriftCache.get(key,BlurResults.class);
    if (results != null) {
      return results;
    }
  }
  BlurResults blurResults=super.query(table,blurQuery);
  if (cacheResult) {
    return _thriftCache.put(key,blurResults);
  }
  return blurResults;
}
Program: 82164
Project: 82164
Buggy source:
@Override public TableStats tableStats(String table) throws BlurException, TException {
  ThriftCacheKey<TableStats> key=_thriftCache.getKey(table,null,TableStats.class);
  TableStats results=_thriftCache.get(key,TableStats.class);
  if (results != null) {
    return results;
  }
  return _thriftCache.put(key,super.tableStats(table));
}

Fixed version (ground truth):
@Override public TableStats tableStats(String table) throws BlurException, TException {
  ThriftCacheKey<TableStats> key=_thriftCache.getKey(table,getShards(table),null,TableStats.class);
  TableStats results=_thriftCache.get(key,TableStats.class);
  if (results != null) {
    return results;
  }
  return _thriftCache.put(key,super.tableStats(table));
}
Program: 82165
Project: 82165
Buggy source:
@Override public List<FetchResult> fetchRowBatch(String table,List<Selector> selectors) throws BlurException, TException {
  Map<Integer,FetchResult> resultMap=new TreeMap<Integer,FetchResult>();
  Map<Integer,Integer> requestMapping=new HashMap<Integer,Integer>();
  List<Selector> selectorRequest=new ArrayList<Selector>();
  for (int i=0; i < selectors.size(); i++) {
    Selector selector=selectors.get(i);
    Selector copy=new Selector(selector);
    ThriftCacheKey<Selector> key=_thriftCache.getKey(table,copy,Selector.class);
    FetchResult fetchResult=_thriftCache.get(key,FetchResult.class);
    if (fetchResult != null) {
      resultMap.put(i,fetchResult);
    }
 else {
      int index=selectorRequest.size();
      requestMapping.put(index,i);
      selectorRequest.add(selector);
    }
  }
  if (selectorRequest.size() != 0) {
    List<FetchResult> missingResults=super.fetchRowBatch(table,selectorRequest);
    for (int i=0; i < missingResults.size(); i++) {
      Selector selector=selectorRequest.get(i);
      FetchResult fetchResult=missingResults.get(i);
      ThriftCacheKey<Selector> key=_thriftCache.getKey(table,new Selector(selector),Selector.class);
      _thriftCache.put(key,fetchResult);
      int originalIndex=requestMapping.get(i);
      resultMap.put(originalIndex,fetchResult);
    }
  }
  return toList(resultMap);
}

Fixed version (ground truth):
@Override public List<FetchResult> fetchRowBatch(String table,List<Selector> selectors) throws BlurException, TException {
  Map<Integer,FetchResult> resultMap=new TreeMap<Integer,FetchResult>();
  Map<Integer,Integer> requestMapping=new HashMap<Integer,Integer>();
  List<Selector> selectorRequest=new ArrayList<Selector>();
  for (int i=0; i < selectors.size(); i++) {
    Selector selector=selectors.get(i);
    Selector copy=new Selector(selector);
    ThriftCacheKey<Selector> key=_thriftCache.getKey(table,getShards(table),copy,Selector.class);
    FetchResult fetchResult=_thriftCache.get(key,FetchResult.class);
    if (fetchResult != null) {
      resultMap.put(i,fetchResult);
    }
 else {
      int index=selectorRequest.size();
      requestMapping.put(index,i);
      selectorRequest.add(selector);
    }
  }
  if (selectorRequest.size() != 0) {
    List<FetchResult> missingResults=super.fetchRowBatch(table,selectorRequest);
    for (int i=0; i < missingResults.size(); i++) {
      Selector selector=selectorRequest.get(i);
      FetchResult fetchResult=missingResults.get(i);
      ThriftCacheKey<Selector> key=_thriftCache.getKey(table,getShards(table),new Selector(selector),Selector.class);
      _thriftCache.put(key,fetchResult);
      int originalIndex=requestMapping.get(i);
      resultMap.put(originalIndex,fetchResult);
    }
  }
  return toList(resultMap);
}
Program: 82166
Project: 82166
Buggy source:
private void commit() throws IOException {
  Tracer trace1=Trace.trace("String_Node_Str");
  waitUntilNotNull(_writer);
  BlurIndexWriter writer=_writer.get();
  writer.prepareCommit();
  trace1.done();
  Tracer trace2=Trace.trace("String_Node_Str");
  writer.commit();
  trace2.done();
  Tracer trace3=Trace.trace("String_Node_Str");
  DirectoryReader currentReader=_indexReader.get();
  DirectoryReader newReader=DirectoryReader.openIfChanged(currentReader);
  if (newReader == null) {
    LOG.debug("String_Node_Str",_tableContext.getTable(),_shardContext.getShard());
  }
 else {
    DirectoryReader reader=wrap(newReader);
    _indexRefreshWriteLock.lock();
    try {
      _indexReader.set(reader);
    }
  finally {
      _indexRefreshWriteLock.unlock();
    }
    _indexCloser.close(currentReader);
  }
  trace3.done();
}

Fixed version (ground truth):
private void commit() throws IOException {
  Tracer trace1=Trace.trace("String_Node_Str");
  waitUntilNotNull(_writer);
  BlurIndexWriter writer=_writer.get();
  writer.prepareCommit();
  trace1.done();
  Tracer trace2=Trace.trace("String_Node_Str");
  writer.commit();
  trace2.done();
  Tracer trace3=Trace.trace("String_Node_Str");
  DirectoryReader currentReader=_indexReader.get();
  DirectoryReader newReader=DirectoryReader.openIfChanged(currentReader);
  if (newReader == null) {
    LOG.debug("String_Node_Str",_tableContext.getTable(),_shardContext.getShard());
  }
 else {
    DirectoryReader reader=wrap(newReader);
    checkForMemoryLeaks(reader,"String_Node_Str");
    _indexRefreshWriteLock.lock();
    try {
      _indexReader.set(reader);
    }
  finally {
      _indexRefreshWriteLock.unlock();
    }
    _indexCloser.close(currentReader);
  }
  trace3.done();
}
Program: 82168
Project: 82168
Buggy source:
private Closeable makeCloseable(final TimerTask timerTask){
  return new Closeable(){
    @Override public void close() throws IOException {
      timerTask.cancel();
    }
  }
;
}

Fixed version (ground truth):
private Closeable makeCloseable(final TimerTask timerTask){
  return new Closeable(){
    @Override public void close() throws IOException {
      timerTask.cancel();
      _bulkIndexingTimer.purge();
    }
  }
;
}
Program: 82169
Project: 82169
Buggy source:
public IndexImporter(Timer indexImporterTimer,BlurIndex blurIndex,ShardContext shardContext,TimeUnit refreshUnit,long refreshAmount){
  _blurIndex=blurIndex;
  _shardContext=shardContext;
  long period=refreshUnit.toMillis(refreshAmount);
  indexImporterTimer.schedule(this,period,period);
  _table=_shardContext.getTableContext().getTable();
  _shard=_shardContext.getShard();
  _cleanupDelay=TimeUnit.MINUTES.toMillis(10);
}

Fixed version (ground truth):
public IndexImporter(Timer indexImporterTimer,BlurIndex blurIndex,ShardContext shardContext,TimeUnit refreshUnit,long refreshAmount){
  _blurIndex=blurIndex;
  _shardContext=shardContext;
  long period=refreshUnit.toMillis(refreshAmount);
  indexImporterTimer.schedule(this,period,period);
  _inindexImporterTimer=indexImporterTimer;
  _table=_shardContext.getTableContext().getTable();
  _shard=_shardContext.getShard();
  _cleanupDelay=TimeUnit.MINUTES.toMillis(10);
}
Program: 82170
Project: 82170
Buggy source:
@Override public void close() throws IOException {
  cancel();
}

Fixed version (ground truth):
@Override public void close() throws IOException {
  cancel();
  _inindexImporterTimer.purge();
}
Program: 82172
Project: 82172
Buggy source:
public ExitableReader(DirectoryReader in,ExitObject exitObject){
  super(in,new ExitableSubReaderWrapper(exitObject));
  _exitObject=exitObject;
}

Fixed version (ground truth):
public ExitableReader(DirectoryReader in,ExitObject exitObject){
  super(in,new ExitableSubReaderWrapper(exitObject));
  _exitObject=exitObject;
  _in=in;
}
Program: 82173
Project: 82173
Buggy source:
public FastHdfsKeyValueDirectory(Timer hdfsKeyValueTimer,Configuration configuration,Path path) throws IOException {
  _path=path;
  _store=new HdfsKeyValueStore(hdfsKeyValueTimer,configuration,path);
  BytesRef value=new BytesRef();
  if (_store.get(FILES,value)) {
    String filesString=value.utf8ToString();
    String[] files=filesString.split("String_Node_Str" + SEP);
    for (    String file : files) {
      if (file.isEmpty()) {
        throw new IOException("String_Node_Str" + filesString + "String_Node_Str");
      }
      BytesRef key=new BytesRef(file + LENGTH);
      if (_store.get(key,value)) {
        _files.put(file,Long.parseLong(value.utf8ToString()));
      }
 else {
        LOG.warn(MISSING_METADATA_MESSAGE,file);
      }
    }
  }
  setLockFactory(NoLockFactory.getNoLockFactory());
  writeFilesNames();
  gc();
}

Fixed version (ground truth):
public FastHdfsKeyValueDirectory(Timer hdfsKeyValueTimer,Configuration configuration,Path path) throws IOException {
  _path=path;
  _store=new HdfsKeyValueStore(hdfsKeyValueTimer,configuration,path);
  MemoryLeakDetector.record(_store,"String_Node_Str",path.toString());
  BytesRef value=new BytesRef();
  if (_store.get(FILES,value)) {
    String filesString=value.utf8ToString();
    String[] files=filesString.split("String_Node_Str" + SEP);
    for (    String file : files) {
      if (file.isEmpty()) {
        throw new IOException("String_Node_Str" + filesString + "String_Node_Str");
      }
      BytesRef key=new BytesRef(file + LENGTH);
      if (_store.get(key,value)) {
        _files.put(file,Long.parseLong(value.utf8ToString()));
      }
 else {
        LOG.warn(MISSING_METADATA_MESSAGE,file);
      }
    }
  }
  setLockFactory(NoLockFactory.getNoLockFactory());
  writeFilesNames();
  gc();
}
Program: 82174
Project: 82174
Buggy source:
public HdfsKeyValueStore(Timer hdfsKeyValueTimer,Configuration configuration,Path path,long maxAmountAllowedPerFile) throws IOException {
  _maxAmountAllowedPerFile=maxAmountAllowedPerFile;
  _path=path;
  _fileSystem=_path.getFileSystem(configuration);
  _fileSystem.mkdirs(_path);
  _readWriteLock=new ReentrantReadWriteLock();
  _writeLock=_readWriteLock.writeLock();
  _readLock=_readWriteLock.readLock();
  _fileStatus.set(getSortedSet(_path));
  if (!_fileStatus.get().isEmpty()) {
    _currentFileCounter.set(Long.parseLong(_fileStatus.get().last().getPath().getName()));
  }
  removeAnyTruncatedFiles();
  loadIndexes();
  cleanupOldFiles();
  _idleLogTimerTask=getIdleLogTimer();
  _oldFileCleanerTimerTask=getOldFileCleanerTimer();
  hdfsKeyValueTimer.schedule(_idleLogTimerTask,DAEMON_POLL_TIME,DAEMON_POLL_TIME);
  hdfsKeyValueTimer.schedule(_oldFileCleanerTimerTask,DAEMON_POLL_TIME,DAEMON_POLL_TIME);
  Metrics.newGauge(new MetricName(ORG_APACHE_BLUR,HDFS_KV,SIZE,path.getParent().toString()),new Gauge<Long>(){
    @Override public Long value(){
      return _size.get();
    }
  }
);
}

Fixed version (ground truth):
public HdfsKeyValueStore(Timer hdfsKeyValueTimer,Configuration configuration,Path path,long maxAmountAllowedPerFile) throws IOException {
  _maxAmountAllowedPerFile=maxAmountAllowedPerFile;
  _path=path;
  _fileSystem=_path.getFileSystem(configuration);
  _fileSystem.mkdirs(_path);
  _readWriteLock=new ReentrantReadWriteLock();
  _writeLock=_readWriteLock.writeLock();
  _readLock=_readWriteLock.readLock();
  _fileStatus.set(getSortedSet(_path));
  if (!_fileStatus.get().isEmpty()) {
    _currentFileCounter.set(Long.parseLong(_fileStatus.get().last().getPath().getName()));
  }
  removeAnyTruncatedFiles();
  loadIndexes();
  cleanupOldFiles();
  _idleLogTimerTask=getIdleLogTimer();
  _oldFileCleanerTimerTask=getOldFileCleanerTimer();
  _hdfsKeyValueTimer=hdfsKeyValueTimer;
  _hdfsKeyValueTimer.schedule(_idleLogTimerTask,DAEMON_POLL_TIME,DAEMON_POLL_TIME);
  _hdfsKeyValueTimer.schedule(_oldFileCleanerTimerTask,DAEMON_POLL_TIME,DAEMON_POLL_TIME);
}
Program: 82175
Project: 82175
Buggy source:
@Override public void close() throws IOException {
  if (!_isClosed) {
    _isClosed=true;
    _idleLogTimerTask.cancel();
    _oldFileCleanerTimerTask.cancel();
    _writeLock.lock();
    try {
      if (isOpenForWriting()) {
        syncInternal();
        _output.close();
        _output=null;
      }
    }
  finally {
      _writeLock.unlock();
    }
  }
}

Fixed version (ground truth):
@Override public void close() throws IOException {
  if (!_isClosed) {
    _isClosed=true;
    _idleLogTimerTask.cancel();
    _oldFileCleanerTimerTask.cancel();
    _hdfsKeyValueTimer.purge();
    _writeLock.lock();
    try {
      if (isOpenForWriting()) {
        syncInternal();
        _output.close();
        _output=null;
      }
    }
  finally {
      _writeLock.unlock();
    }
  }
}
Program: 82180
Project: 82180
Buggy source:
private BlurIndex openIndex(String table,String shard,Directory dir) throws CorruptIndexException, IOException {
  ShardContext shardContext=ShardContext.create(_tableContext,shard);
  BlurIndexSimpleWriter index=new BlurIndexSimpleWriter(shardContext,dir,_mergeScheduler,_searchExecutor,_indexCloser,_timer);
  return index;
}

Fixed version (ground truth):
private BlurIndex openIndex(String table,String shard,Directory dir) throws CorruptIndexException, IOException {
  ShardContext shardContext=ShardContext.create(_tableContext,shard);
  BlurIndexSimpleWriter index=new BlurIndexSimpleWriter(shardContext,dir,_mergeScheduler,_searchExecutor,_indexCloser,_timer,_bulkTimer);
  return index;
}
Program: 82181
Project: 82181
Buggy source:
public LocalIndexServer(TableDescriptor tableDescriptor,boolean ramDir) throws IOException {
  _timer=new Timer("String_Node_Str",true);
  _closer=Closer.create();
  _tableContext=TableContext.create(tableDescriptor);
  _mergeScheduler=_closer.register(new SharedMergeScheduler(3,128 * 1000 * 1000));
  _searchExecutor=Executors.newCachedThreadPool();
  _closer.register(new CloseableExecutorService(_searchExecutor));
  _ramDir=ramDir;
  _indexCloser=_closer.register(new BlurIndexCloser());
  _closer.register(new Closeable(){
    @Override public void close() throws IOException {
      _timer.cancel();
      _timer.purge();
    }
  }
);
  getIndexes(_tableContext.getTable());
}

Fixed version (ground truth):
public LocalIndexServer(TableDescriptor tableDescriptor,boolean ramDir) throws IOException {
  _timer=new Timer("String_Node_Str",true);
  _bulkTimer=new Timer("String_Node_Str",true);
  _closer=Closer.create();
  _tableContext=TableContext.create(tableDescriptor);
  _mergeScheduler=_closer.register(new SharedMergeScheduler(3,128 * 1000 * 1000));
  _searchExecutor=Executors.newCachedThreadPool();
  _closer.register(new CloseableExecutorService(_searchExecutor));
  _ramDir=ramDir;
  _indexCloser=_closer.register(new BlurIndexCloser());
  _closer.register(new Closeable(){
    @Override public void close() throws IOException {
      _timer.cancel();
      _timer.purge();
    }
  }
);
  getIndexes(_tableContext.getTable());
}
Program: 82182
Project: 82182
Buggy source:
public BlurIndex(ShardContext shardContext,Directory directory,SharedMergeScheduler mergeScheduler,ExecutorService searchExecutor,BlurIndexCloser indexCloser,Timer indexImporterTimer) throws IOException {
  _shardContext=shardContext;
}

Fixed version (ground truth):
public BlurIndex(ShardContext shardContext,Directory directory,SharedMergeScheduler mergeScheduler,ExecutorService searchExecutor,BlurIndexCloser indexCloser,Timer indexImporterTimer,Timer bulkIndexingTimer) throws IOException {
  _shardContext=shardContext;
}
Program: 82183
Project: 82183
Buggy source:
public BlurIndexReadOnly(BlurIndex blurIndex) throws IOException {
  super(null,null,null,null,null,null);
  _blurIndex=blurIndex;
}

Fixed version (ground truth):
public BlurIndexReadOnly(BlurIndex blurIndex) throws IOException {
  super(null,null,null,null,null,null,null);
  _blurIndex=blurIndex;
}
Program: 82184
Project: 82184
Buggy source:
private BlockingQueue<CacheValue> getPool(int cacheBlockSize){
  BlockingQueue<CacheValue> blockingQueue=_cacheValuePool.get(_cacheValuePool);
  if (blockingQueue == null) {
    blockingQueue=buildNewBlockQueue(cacheBlockSize);
  }
  return blockingQueue;
}

Fixed version (ground truth):
private BlockingQueue<CacheValue> getPool(int cacheBlockSize){
  BlockingQueue<CacheValue> blockingQueue=_cacheValuePool.get(cacheBlockSize);
  if (blockingQueue == null) {
    blockingQueue=buildNewBlockQueue(cacheBlockSize);
  }
  return blockingQueue;
}
Program: 82185
Project: 82185
Buggy source:
private BlockingQueue<CacheValue> buildNewBlockQueue(int cacheBlockSize){
  _cacheValuePool.putIfAbsent(cacheBlockSize,new ArrayBlockingQueue<CacheValue>(_capacity));
  return _cacheValuePool.get(cacheBlockSize);
}

Fixed version (ground truth):
private BlockingQueue<CacheValue> buildNewBlockQueue(int cacheBlockSize){
  LOG.info("String_Node_Str",_capacity);
  BlockingQueue<CacheValue> value=new ArrayBlockingQueue<CacheValue>(_capacity);
  _cacheValuePool.putIfAbsent(cacheBlockSize,value);
  return _cacheValuePool.get(cacheBlockSize);
}
Program: 82186
Project: 82186
Buggy source:
public static Object runInternalReturnThriftObject(String name,Arguments arguments,Connection... connectionsArray) throws TTransportException, IOException, BlurException, TimeoutException, TException {
  List<Connection> connections=new ArrayList<Connection>(Arrays.asList(connectionsArray));
  Collections.shuffle(connections);
  for (  Connection connection : connections) {
    if (BlurClientManager.isBadConnection(connection)) {
      continue;
    }
    ClientPool clientPool=BlurClientManager.getClientPool();
    Client client=clientPool.getClient(connection);
    try {
      Long executionId=null;
      Response response;
      INNER:       while (true) {
        try {
          if (executionId == null) {
            response=client.execute(name,arguments);
          }
 else {
            response=client.reconnect(executionId);
          }
          break INNER;
        }
 catch (        TimeoutException te) {
          executionId=te.getInstanceExecutionId();
        }
      }
      return CommandUtil.fromThriftResponseToObject(response);
    }
  finally {
      clientPool.returnClient(connection,client);
    }
  }
  throw new BlurException("String_Node_Str" + connections + "String_Node_Str",null,ErrorType.UNKNOWN);
}

Fixed version (ground truth):
public static Object runInternalReturnThriftObject(String name,Arguments arguments,Connection... connectionsArray) throws TTransportException, IOException, BlurException, TimeoutException, TException {
  List<Connection> connections=new ArrayList<Connection>(Arrays.asList(connectionsArray));
  Collections.shuffle(connections);
  for (  Connection connection : connections) {
    if (BlurClientManager.isBadConnection(connection)) {
      continue;
    }
    ClientPool clientPool=BlurClientManager.getClientPool();
    Client client=clientPool.getClient(connection);
    try {
      Long executionId=null;
      Response response;
      INNER:       while (true) {
        Tracer tracer=BlurClientManager.setupClientPreCall(client);
        try {
          if (executionId == null) {
            response=client.execute(name,arguments);
          }
 else {
            response=client.reconnect(executionId);
          }
          break INNER;
        }
 catch (        TimeoutException te) {
          executionId=te.getInstanceExecutionId();
        }
 finally {
          if (tracer != null) {
            tracer.done();
          }
        }
      }
      return CommandUtil.fromThriftResponseToObject(response);
    }
  finally {
      clientPool.returnClient(connection,client);
    }
  }
  throw new BlurException("String_Node_Str" + connections + "String_Node_Str",null,ErrorType.UNKNOWN);
}
Program: 82187
Project: 82187
Buggy source:
protected static Response waitForResponse(Client client,Command<?> command,Arguments arguments) throws TException {
  Long executionId=null;
  while (true) {
    try {
      if (executionId == null) {
        return client.execute(command.getName(),arguments);
      }
 else {
        return client.reconnect(executionId);
      }
    }
 catch (    BlurException e) {
      throw e;
    }
catch (    TimeoutException e) {
      executionId=e.getInstanceExecutionId();
      LOG.info("String_Node_Str",executionId);
    }
catch (    TException e) {
      throw e;
    }
  }
}

Fixed version (ground truth):
protected static Response waitForResponse(Client client,Command<?> command,Arguments arguments) throws TException {
  Long executionId=null;
  while (true) {
    Tracer tracer=BlurClientManager.setupClientPreCall(client);
    try {
      if (executionId == null) {
        return client.execute(command.getName(),arguments);
      }
 else {
        return client.reconnect(executionId);
      }
    }
 catch (    BlurException e) {
      throw e;
    }
catch (    TimeoutException e) {
      executionId=e.getInstanceExecutionId();
      LOG.info("String_Node_Str",executionId);
    }
catch (    TException e) {
      throw e;
    }
 finally {
      if (tracer != null) {
        tracer.done();
      }
    }
  }
}
Program: 82188
Project: 82188
Buggy source:
@Override public void doPostCommit(IndexWriter writer) throws IOException {
  LOG.info("String_Node_Str",_shard,_table);
  writer.maybeMerge();
}

Fixed version (ground truth):
@Override public void doPostCommit(IndexWriter writer) throws IOException {
  Path path=directory.getPath();
  fileSystem.delete(new Path(path,INPROGRESS),false);
  LOG.info("String_Node_Str",_shard,_table);
  writer.maybeMerge();
}
Program: 82190
Project: 82190
Buggy source:
public void cleanupOldDirs() throws IOException {
  Path hdfsDirPath=_shardContext.getHdfsDirPath();
  TableContext tableContext=_shardContext.getTableContext();
  Configuration configuration=tableContext.getConfiguration();
  FileSystem fileSystem=hdfsDirPath.getFileSystem(configuration);
  FileStatus[] inuseSubDirs=fileSystem.listStatus(hdfsDirPath,new PathFilter(){
    @Override public boolean accept(    Path path){
      return path.getName().endsWith(INUSE);
    }
  }
);
  Set<Path> inuseDirs=toSet(inuseSubDirs);
  Map<Path,Path> inuseFileToDir=toMap(fileSystem,inuseDirs);
  FileStatus[] listStatus=fileSystem.listStatus(hdfsDirPath,new PathFilter(){
    @Override public boolean accept(    Path path){
      return path.getName().endsWith(HdfsDirectory.LNK);
    }
  }
);
  for (  FileStatus status : listStatus) {
    Path realPath=HdfsDirectory.readRealPathDataFromSymlinkPath(fileSystem,status.getPath());
    Path inuseDir=inuseFileToDir.get(realPath);
    inuseDirs.remove(inuseDir);
  }
  for (  Path p : inuseDirs) {
    LOG.info("String_Node_Str",p);
    fileSystem.delete(p,true);
  }
}

Fixed version (ground truth):
public void cleanupOldDirs() throws IOException {
  Path hdfsDirPath=_shardContext.getHdfsDirPath();
  TableContext tableContext=_shardContext.getTableContext();
  Configuration configuration=tableContext.getConfiguration();
  FileSystem fileSystem=hdfsDirPath.getFileSystem(configuration);
  FileStatus[] inuseSubDirs=fileSystem.listStatus(hdfsDirPath,new PathFilter(){
    @Override public boolean accept(    Path path){
      return path.getName().endsWith(INUSE);
    }
  }
);
  Set<Path> inuseDirs=toSet(inuseSubDirs);
  Map<Path,Path> inuseFileToDir=toMap(fileSystem,inuseDirs);
  FileStatus[] listStatus=fileSystem.listStatus(hdfsDirPath,new PathFilter(){
    @Override public boolean accept(    Path path){
      return path.getName().endsWith(HdfsDirectory.LNK);
    }
  }
);
  for (  FileStatus status : listStatus) {
    Path realPath=HdfsDirectory.readRealPathDataFromSymlinkPath(fileSystem,status.getPath());
    Path inuseDir=inuseFileToDir.get(realPath);
    inuseDirs.remove(inuseDir);
  }
  for (  Path inuse : new HashSet<Path>(inuseDirs)) {
    Path path=new Path(inuse,INPROGRESS);
    if (fileSystem.exists(path)) {
      LOG.info("String_Node_Str",path);
      inuseDirs.remove(inuse);
      Path commit=new Path(inuse.getParent(),rename(inuse.getName(),COMMIT));
      fileSystem.rename(inuse,commit);
    }
  }
  for (  Path p : inuseDirs) {
    LOG.info("String_Node_Str",p);
    fileSystem.delete(p,true);
  }
}
Program: 82191
Project: 82191
Buggy source:
private IndexAction getIndexAction(final HdfsDirectory directory,final FileSystem fileSystem){
  return new IndexAction(){
    @Override public void performMutate(    IndexSearcherCloseable searcher,    IndexWriter writer) throws IOException {
      LOG.info("String_Node_Str",directory,_shard,_table);
      boolean emitDeletes=searcher.getIndexReader().numDocs() != 0;
      applyDeletes(directory,writer,_shard,emitDeletes);
      LOG.info("String_Node_Str",directory,_shard,_table);
      writer.addIndexes(directory);
      LOG.info("String_Node_Str",directory,_shard,_table);
      writer.deleteDocuments(new Term(BlurConstants.DELETE_MARKER,BlurConstants.DELETE_MARKER_VALUE));
      LOG.info("String_Node_Str",directory,_shard,_table);
    }
    @Override public void doPreCommit(    IndexSearcherCloseable indexSearcher,    IndexWriter writer) throws IOException {
    }
    @Override public void doPostCommit(    IndexWriter writer) throws IOException {
      LOG.info("String_Node_Str",_shard,_table);
      writer.maybeMerge();
    }
    @Override public void doPreRollback(    IndexWriter writer) throws IOException {
      LOG.info("String_Node_Str",_shard,_table);
    }
    @Override public void doPostRollback(    IndexWriter writer) throws IOException {
      LOG.info("String_Node_Str",_shard,_table);
      Path path=directory.getPath();
      String name=path.getName();
      fileSystem.rename(path,new Path(path.getParent(),rename(name,BADROWIDS)));
    }
  }
;
}

Fixed version (ground truth):
private IndexAction getIndexAction(final HdfsDirectory directory,final FileSystem fileSystem){
  return new IndexAction(){
    @Override public void performMutate(    IndexSearcherCloseable searcher,    IndexWriter writer) throws IOException {
      LOG.info("String_Node_Str",directory,_shard,_table);
      boolean emitDeletes=searcher.getIndexReader().numDocs() != 0;
      applyDeletes(directory,writer,_shard,emitDeletes);
      LOG.info("String_Node_Str",directory,_shard,_table);
      writer.addIndexes(directory);
      LOG.info("String_Node_Str",directory,_shard,_table);
      writer.deleteDocuments(new Term(BlurConstants.DELETE_MARKER,BlurConstants.DELETE_MARKER_VALUE));
      LOG.info("String_Node_Str",directory,_shard,_table);
    }
    @Override public void doPreCommit(    IndexSearcherCloseable indexSearcher,    IndexWriter writer) throws IOException {
    }
    @Override public void doPostCommit(    IndexWriter writer) throws IOException {
      Path path=directory.getPath();
      fileSystem.delete(new Path(path,INPROGRESS),false);
      LOG.info("String_Node_Str",_shard,_table);
      writer.maybeMerge();
    }
    @Override public void doPreRollback(    IndexWriter writer) throws IOException {
      LOG.info("String_Node_Str",_shard,_table);
    }
    @Override public void doPostRollback(    IndexWriter writer) throws IOException {
      LOG.info("String_Node_Str",_shard,_table);
      Path path=directory.getPath();
      String name=path.getName();
      fileSystem.rename(path,new Path(path.getParent(),rename(name,BADROWIDS)));
    }
  }
;
}