Program: 82167
Project: 82167
Buggy source:
public BlurIndexSimpleWriter(ShardContext shardContext,Directory directory,SharedMergeScheduler mergeScheduler,final ExecutorService searchExecutor,BlurIndexCloser indexCloser,Timer indexImporterTimer,Timer bulkIndexingTimer,ThriftCache thriftCache) throws IOException {
  super(shardContext,directory,mergeScheduler,searchExecutor,indexCloser,indexImporterTimer,bulkIndexingTimer,thriftCache);
  _thriftCache=thriftCache;
  _commaSplitter=Splitter.on(',');
  _bulkWriters=new ConcurrentHashMap<String,BlurIndexSimpleWriter.BulkEntry>();
  _indexImporterTimer=indexImporterTimer;
  _bulkIndexingTimer=bulkIndexingTimer;
  _searchThreadPool=searchExecutor;
  _shardContext=shardContext;
  _tableContext=_shardContext.getTableContext();
  _context=_tableContext.getTable() + "String_Node_Str" + shardContext.getShard();
  _fieldManager=_tableContext.getFieldManager();
  _discoverableFields=_tableContext.getDiscoverableFields();
  _accessControlFactory=_tableContext.getAccessControlFactory();
  TableDescriptor descriptor=_tableContext.getDescriptor();
  Map<String,String> tableProperties=descriptor.getTableProperties();
  if (tableProperties != null) {
    String value=tableProperties.get(BlurConstants.BLUR_RECORD_SECURITY);
    if (value != null && value.equals(TRUE)) {
      LOG.info("String_Node_Str",_tableContext.getTable(),_shardContext.getShard());
      _security=true;
    }
 else {
      _security=false;
    }
  }
 else {
    _security=false;
  }
  Analyzer analyzer=_fieldManager.getAnalyzerForIndex();
  _conf=new IndexWriterConfig(LUCENE_VERSION,analyzer);
  _conf.setWriteLockTimeout(TimeUnit.MINUTES.toMillis(5));
  _conf.setCodec(new Blur024Codec(_tableContext.getBlurConfiguration()));
  _conf.setSimilarity(_tableContext.getSimilarity());
  _conf.setInfoStream(new LoggingInfoStream(_tableContext.getTable(),_shardContext.getShard()));
  TieredMergePolicy mergePolicy=(TieredMergePolicy)_conf.getMergePolicy();
  mergePolicy.setUseCompoundFile(false);
  _conf.setMergeScheduler(mergeScheduler.getMergeScheduler());
  _snapshotIndexDeletionPolicy=new SnapshotIndexDeletionPolicy(_tableContext.getConfiguration(),new Path(shardContext.getHdfsDirPath(),"String_Node_Str"));
  _policy=new IndexDeletionPolicyReader(_snapshotIndexDeletionPolicy);
  _conf.setIndexDeletionPolicy(_policy);
  BlurConfiguration blurConfiguration=_tableContext.getBlurConfiguration();
  _queue=new ArrayBlockingQueue<RowMutation>(blurConfiguration.getInt(BLUR_SHARD_QUEUE_MAX_INMEMORY_LENGTH,100));
  _mutationQueueProcessor=new MutationQueueProcessor(_queue,this,_shardContext,_writesWaiting);
  if (!DirectoryReader.indexExists(directory)) {
    new BlurIndexWriter(directory,_conf).close();
  }
  _directory=directory;
  _indexCloser=indexCloser;
  _indexReader.set(wrap(DirectoryReader.open(_directory)));
  openWriter();
  _watchForIdleBulkWriters=new TimerTask(){
    @Override public void run(){
      for (      BulkEntry bulkEntry : _bulkWriters.values()) {
        bulkEntry._lock.lock();
        try {
          if (!bulkEntry.isClosed() && bulkEntry.isIdle()) {
            LOG.info("String_Node_Str",bulkEntry);
            try {
              bulkEntry.close();
            }
 catch (            IOException e) {
              LOG.error("String_Node_Str",e);
            }
          }
        }
  finally {
          bulkEntry._lock.unlock();
        }
      }
    }
  }
;
  long delay=TimeUnit.SECONDS.toMillis(30);
  _bulkIndexingTimer.schedule(_watchForIdleBulkWriters,delay,delay);
}

Fixed version (ground truth):
public BlurIndexSimpleWriter(ShardContext shardContext,Directory directory,SharedMergeScheduler mergeScheduler,final ExecutorService searchExecutor,BlurIndexCloser indexCloser,Timer indexImporterTimer,Timer bulkIndexingTimer,ThriftCache thriftCache) throws IOException {
  super(shardContext,directory,mergeScheduler,searchExecutor,indexCloser,indexImporterTimer,bulkIndexingTimer,thriftCache);
  _thriftCache=thriftCache;
  _commaSplitter=Splitter.on(',');
  _bulkWriters=new ConcurrentHashMap<String,BlurIndexSimpleWriter.BulkEntry>();
  _indexImporterTimer=indexImporterTimer;
  _bulkIndexingTimer=bulkIndexingTimer;
  _searchThreadPool=searchExecutor;
  _shardContext=shardContext;
  _tableContext=_shardContext.getTableContext();
  _context=_tableContext.getTable() + "String_Node_Str" + shardContext.getShard();
  _fieldManager=_tableContext.getFieldManager();
  _discoverableFields=_tableContext.getDiscoverableFields();
  _accessControlFactory=_tableContext.getAccessControlFactory();
  TableDescriptor descriptor=_tableContext.getDescriptor();
  Map<String,String> tableProperties=descriptor.getTableProperties();
  if (tableProperties != null) {
    String value=tableProperties.get(BlurConstants.BLUR_RECORD_SECURITY);
    if (value != null && value.equals(TRUE)) {
      LOG.info("String_Node_Str",_tableContext.getTable(),_shardContext.getShard());
      _security=true;
    }
 else {
      _security=false;
    }
  }
 else {
    _security=false;
  }
  Analyzer analyzer=_fieldManager.getAnalyzerForIndex();
  _conf=new IndexWriterConfig(LUCENE_VERSION,analyzer);
  _conf.setWriteLockTimeout(TimeUnit.MINUTES.toMillis(5));
  _conf.setCodec(new Blur024Codec(_tableContext.getBlurConfiguration()));
  _conf.setSimilarity(_tableContext.getSimilarity());
  _conf.setInfoStream(new LoggingInfoStream(_tableContext.getTable(),_shardContext.getShard()));
  TieredMergePolicy mergePolicy=(TieredMergePolicy)_conf.getMergePolicy();
  mergePolicy.setUseCompoundFile(false);
  _conf.setMergeScheduler(mergeScheduler.getMergeScheduler());
  _snapshotIndexDeletionPolicy=new SnapshotIndexDeletionPolicy(_tableContext.getConfiguration(),new Path(shardContext.getHdfsDirPath(),"String_Node_Str"));
  _policy=new IndexDeletionPolicyReader(_snapshotIndexDeletionPolicy);
  _conf.setIndexDeletionPolicy(_policy);
  BlurConfiguration blurConfiguration=_tableContext.getBlurConfiguration();
  _queue=new ArrayBlockingQueue<RowMutation>(blurConfiguration.getInt(BLUR_SHARD_QUEUE_MAX_INMEMORY_LENGTH,100));
  _mutationQueueProcessor=new MutationQueueProcessor(_queue,this,_shardContext,_writesWaiting);
  if (!DirectoryReader.indexExists(directory)) {
    new BlurIndexWriter(directory,_conf).close();
  }
  _directory=directory;
  _indexCloser=indexCloser;
  DirectoryReader realDirectoryReader=DirectoryReader.open(_directory);
  DirectoryReader wrappped=wrap(realDirectoryReader);
  String message="String_Node_Str";
  DirectoryReader directoryReader=checkForMemoryLeaks(wrappped,message);
  _indexReader.set(directoryReader);
  openWriter();
  _watchForIdleBulkWriters=new TimerTask(){
    @Override public void run(){
      for (      BulkEntry bulkEntry : _bulkWriters.values()) {
        bulkEntry._lock.lock();
        try {
          if (!bulkEntry.isClosed() && bulkEntry.isIdle()) {
            LOG.info("String_Node_Str",bulkEntry);
            try {
              bulkEntry.close();
            }
 catch (            IOException e) {
              LOG.error("String_Node_Str",e);
            }
          }
        }
  finally {
          bulkEntry._lock.unlock();
        }
      }
    }
  }
;
  long delay=TimeUnit.SECONDS.toMillis(30);
  _bulkIndexingTimer.schedule(_watchForIdleBulkWriters,delay,delay);
}