nus-yam/ex-repair huggingface dataset:
Program: 47693
Project: 47693
Buggy source:
@Override public void saveEntryIndex(QueryableEntry e) throws QueryException {
  if (attributeType == null) {
    attributeType=e.getAttributeType(attribute);
  }
  Data key=e.getIndexKey();
  Comparable oldValue=recordValues.remove(key);
  Comparable newValue=e.getAttribute(attribute);
  if (newValue == null) {
    newValue=NULL;
  }
 else   if (newValue.getClass().isEnum()) {
    newValue=TypeConverters.ENUM_CONVERTER.convert(newValue);
  }
  recordValues.put(key,newValue);
  if (oldValue == null) {
    indexStore.newIndex(newValue,e);
  }
 else {
    indexStore.removeIndex(oldValue,key);
    indexStore.newIndex(newValue,e);
  }
}

Fixed version (ground truth):
@Override public void saveEntryIndex(QueryableEntry e) throws QueryException {
  if (attributeType == null) {
    attributeType=e.getAttributeType(attribute);
  }
  Data key=e.getIndexKey();
  Comparable oldValue=recordValues.remove(key);
  Comparable newValue=e.getAttribute(attribute);
  if (newValue == null) {
    newValue=NULL;
  }
 else   if (newValue.getClass().isEnum()) {
    newValue=TypeConverters.ENUM_CONVERTER.convert(newValue);
  }
  recordValues.put(key,newValue);
  if (oldValue == null) {
    indexStore.newIndex(newValue,e);
  }
 else {
    indexStore.updateIndex(oldValue,newValue,e);
  }
}
Program: 47694
Project: 47694
Buggy source:
@Override public void getSubRecords(MultiResultSet results,ComparisonType comparisonType,Comparable searchedValue){
  Set<Comparable> values;
  boolean notEqual=false;
switch (comparisonType) {
case LESSER:
    values=sortedSet.headSet(searchedValue,false);
  break;
case LESSER_EQUAL:
values=sortedSet.headSet(searchedValue,true);
break;
case GREATER:
values=sortedSet.tailSet(searchedValue,false);
break;
case GREATER_EQUAL:
values=sortedSet.tailSet(searchedValue,true);
break;
case NOT_EQUAL:
values=sortedSet;
notEqual=true;
break;
default :
throw new IllegalArgumentException("String_Node_Str" + comparisonType);
}
for (Comparable value : values) {
if (notEqual && searchedValue.equals(value)) {
continue;
}
ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(value);
if (records != null) {
results.addResultSet(records);
}
}
}

Fixed version (ground truth):
@Override public void getSubRecords(MultiResultSet results,ComparisonType comparisonType,Comparable searchedValue){
  takeReadLock();
  try {
    SortedMap<Comparable,ConcurrentMap<Data,QueryableEntry>> subMap;
switch (comparisonType) {
case LESSER:
      subMap=recordMap.headMap(searchedValue,false);
    break;
case LESSER_EQUAL:
  subMap=recordMap.headMap(searchedValue,true);
break;
case GREATER:
subMap=recordMap.tailMap(searchedValue,false);
break;
case GREATER_EQUAL:
subMap=recordMap.tailMap(searchedValue,true);
break;
case NOT_EQUAL:
for (Map.Entry<Comparable,ConcurrentMap<Data,QueryableEntry>> entry : recordMap.entrySet()) {
if (!searchedValue.equals(entry.getKey())) {
results.addResultSet(entry.getValue());
}
}
return;
default :
throw new IllegalArgumentException("String_Node_Str" + comparisonType);
}
for (ConcurrentMap<Data,QueryableEntry> value : subMap.values()) {
results.addResultSet(value);
}
}
  finally {
releaseReadLock();
}
}
Program: 47695
Project: 47695
Buggy source:
@Override public ConcurrentMap<Data,QueryableEntry> getRecordMap(Comparable indexValue){
  return mapRecords.get(indexValue);
}

Fixed version (ground truth):
@Override public ConcurrentMap<Data,QueryableEntry> getRecordMap(Comparable value){
  takeReadLock();
  try {
    if (value instanceof IndexImpl.NullObject) {
      return recordsWithNullValue;
    }
 else {
      return recordMap.get(value);
    }
  }
  finally {
    releaseReadLock();
  }
}
Program: 47696
Project: 47696
Buggy source:
@Override public void clear(){
  mapRecords.clear();
  sortedSet.clear();
}

Fixed version (ground truth):
@Override public void clear(){
  takeWriteLock();
  try {
    recordsWithNullValue.clear();
    recordMap.clear();
  }
  finally {
    releaseWriteLock();
  }
}
Program: 47697
Project: 47697
Buggy source:
@Override public void getRecords(MultiResultSet results,Set<Comparable> values){
  for (  Comparable value : values) {
    ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(value);
    if (records != null) {
      results.addResultSet(records);
    }
  }
}

Fixed version (ground truth):
@Override public void getRecords(MultiResultSet results,Set<Comparable> values){
  takeReadLock();
  try {
    for (    Comparable value : values) {
      ConcurrentMap<Data,QueryableEntry> records;
      if (value instanceof IndexImpl.NullObject) {
        records=recordsWithNullValue;
      }
 else {
        records=recordMap.get(value);
      }
      if (records != null) {
        results.addResultSet(records);
      }
    }
  }
  finally {
    releaseReadLock();
  }
}
Program: 47698
Project: 47698
Buggy source:
@Override public void removeIndex(Comparable oldValue,Data indexKey){
  ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(oldValue);
  if (records != null) {
    records.remove(indexKey);
    if (records.size() == 0) {
      mapRecords.remove(oldValue);
      sortedSet.remove(oldValue);
    }
  }
}

Fixed version (ground truth):
@Override public void removeIndex(Comparable oldValue,Data indexKey){
  takeWriteLock();
  try {
    if (oldValue instanceof IndexImpl.NullObject) {
      recordsWithNullValue.remove(indexKey);
    }
 else {
      ConcurrentMap<Data,QueryableEntry> records=recordMap.get(oldValue);
      if (records != null) {
        records.remove(indexKey);
        if (records.size() == 0) {
          recordMap.remove(oldValue);
        }
      }
    }
  }
  finally {
    releaseWriteLock();
  }
}
Program: 47699
Project: 47699
Buggy source:
@Override public void getSubRecordsBetween(MultiResultSet results,Comparable from,Comparable to){
  Set<Comparable> values=sortedSet.subSet(from,to);
  for (  Comparable value : values) {
    ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(value);
    if (records != null) {
      results.addResultSet(records);
    }
  }
  ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(to);
  if (records != null) {
    results.addResultSet(records);
  }
}

Fixed version (ground truth):
@Override public void getSubRecordsBetween(MultiResultSet results,Comparable from,Comparable to){
  takeReadLock();
  try {
    SortedMap<Comparable,ConcurrentMap<Data,QueryableEntry>> subMap=recordMap.subMap(from,true,to,true);
    for (    ConcurrentMap<Data,QueryableEntry> value : subMap.values()) {
      results.addResultSet(value);
    }
  }
  finally {
    releaseReadLock();
  }
}
Program: 47700
Project: 47700
Buggy source:
@Override public String toString(){
  return "String_Node_Str" + "String_Node_Str" + mapRecords.size() + '}';
}

Fixed version (ground truth):
@Override public String toString(){
  return "String_Node_Str" + "String_Node_Str" + recordMap.size() + '}';
}
Program: 47701
Project: 47701
Buggy source:
@Override public void newIndex(Comparable newValue,QueryableEntry record){
  ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(newValue);
  if (records == null) {
    records=new ConcurrentHashMap<Data,QueryableEntry>(1,LOAD_FACTOR,1);
    mapRecords.put(newValue,records);
    if (!(newValue instanceof IndexImpl.NullObject)) {
      sortedSet.add(newValue);
    }
  }
  records.put(record.getIndexKey(),record);
}

Fixed version (ground truth):
@Override public void newIndex(Comparable newValue,QueryableEntry record){
  takeWriteLock();
  try {
    if (newValue instanceof IndexImpl.NullObject) {
      recordsWithNullValue.put(record.getIndexKey(),record);
    }
 else {
      ConcurrentMap<Data,QueryableEntry> records=recordMap.get(newValue);
      if (records == null) {
        records=new ConcurrentHashMap<Data,QueryableEntry>(1,LOAD_FACTOR,1);
        recordMap.put(newValue,records);
      }
      records.put(record.getIndexKey(),record);
    }
  }
  finally {
    releaseWriteLock();
  }
}
Program: 47702
Project: 47702
Buggy source:
@Override public void getRecords(MultiResultSet results,Set<Comparable> values){
  takeReadLock();
  try {
    for (    Comparable value : values) {
      ConcurrentMap<Data,QueryableEntry> records=null;
      if (value instanceof IndexImpl.NullObject) {
        records=recordsWithNullValue;
      }
 else {
        records=recordMap.get(value);
      }
      if (records != null) {
        results.addResultSet(records);
      }
    }
  }
  finally {
    releaseReadLock();
  }
}

Fixed version (ground truth):
@Override public void getRecords(MultiResultSet results,Set<Comparable> values){
  takeReadLock();
  try {
    for (    Comparable value : values) {
      ConcurrentMap<Data,QueryableEntry> records;
      if (value instanceof IndexImpl.NullObject) {
        records=recordsWithNullValue;
      }
 else {
        records=recordMap.get(value);
      }
      if (records != null) {
        results.addResultSet(records);
      }
    }
  }
  finally {
    releaseReadLock();
  }
}
Program: 47703
Project: 47703
Buggy source:
@Override public void getSubRecordsBetween(MultiResultSet results,Comparable from,Comparable to){
  takeReadLock();
  try {
    SortedMap<Comparable,ConcurrentMap<Data,QueryableEntry>> subMap=recordMap.subMap(from,to);
    for (    ConcurrentMap<Data,QueryableEntry> value : subMap.values()) {
      results.addResultSet(value);
    }
  }
  finally {
    releaseReadLock();
  }
}

Fixed version (ground truth):
@Override public void getSubRecordsBetween(MultiResultSet results,Comparable from,Comparable to){
  takeReadLock();
  try {
    SortedMap<Comparable,ConcurrentMap<Data,QueryableEntry>> subMap=recordMap.subMap(from,true,to,true);
    for (    ConcurrentMap<Data,QueryableEntry> value : subMap.values()) {
      results.addResultSet(value);
    }
  }
  finally {
    releaseReadLock();
  }
}
Program: 47704
Project: 47704
Buggy source:
@Override public void getSubRecords(MultiResultSet results,ComparisonType comparisonType,Comparable searchedValue){
  takeReadLock();
  try {
    Set<Comparable> values=mapRecords.keySet();
    for (    Comparable value : values) {
      boolean valid;
      int result=value.compareTo(searchedValue);
switch (comparisonType) {
case LESSER:
        valid=result < 0;
      break;
case LESSER_EQUAL:
    valid=result <= 0;
  break;
case GREATER:
valid=result > 0;
break;
case GREATER_EQUAL:
valid=result >= 0;
break;
case NOT_EQUAL:
valid=result != 0;
break;
default :
throw new IllegalStateException("String_Node_Str" + comparisonType);
}
if (valid) {
ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(value);
if (records != null) {
results.addResultSet(records);
}
}
}
}
  finally {
releaseReadLock();
}
}

Fixed version (ground truth):
@Override public void getSubRecords(MultiResultSet results,ComparisonType comparisonType,Comparable searchedValue){
  takeReadLock();
  try {
    Set<Comparable> values=recordMap.keySet();
    for (    Comparable value : values) {
      boolean valid;
      int result=value.compareTo(searchedValue);
switch (comparisonType) {
case LESSER:
        valid=result < 0;
      break;
case LESSER_EQUAL:
    valid=result <= 0;
  break;
case GREATER:
valid=result > 0;
break;
case GREATER_EQUAL:
valid=result >= 0;
break;
case NOT_EQUAL:
valid=result != 0;
break;
default :
throw new IllegalStateException("String_Node_Str" + comparisonType);
}
if (valid) {
ConcurrentMap<Data,QueryableEntry> records=recordMap.get(value);
if (records != null) {
results.addResultSet(records);
}
}
}
}
  finally {
releaseReadLock();
}
}
Program: 47705
Project: 47705
Buggy source:
@Override public ConcurrentMap<Data,QueryableEntry> getRecordMap(Comparable indexValue){
  takeReadLock();
  try {
    return mapRecords.get(indexValue);
  }
  finally {
    releaseReadLock();
  }
}

Fixed version (ground truth):
@Override public ConcurrentMap<Data,QueryableEntry> getRecordMap(Comparable value){
  takeReadLock();
  try {
    if (value instanceof IndexImpl.NullObject) {
      return recordsWithNullValue;
    }
 else {
      return recordMap.get(value);
    }
  }
  finally {
    releaseReadLock();
  }
}
Program: 47706
Project: 47706
Buggy source:
@Override public void clear(){
  takeWriteLock();
  try {
    mapRecords.clear();
  }
  finally {
    releaseWriteLock();
  }
}

Fixed version (ground truth):
@Override public void clear(){
  takeWriteLock();
  try {
    recordsWithNullValue.clear();
    recordMap.clear();
  }
  finally {
    releaseWriteLock();
  }
}
Program: 47707
Project: 47707
Buggy source:
@Override public void getRecords(MultiResultSet results,Set<Comparable> values){
  takeReadLock();
  try {
    for (    Comparable value : values) {
      ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(value);
      if (records != null) {
        results.addResultSet(records);
      }
    }
  }
  finally {
    releaseReadLock();
  }
}

Fixed version (ground truth):
@Override public void getRecords(MultiResultSet results,Set<Comparable> values){
  takeReadLock();
  try {
    for (    Comparable value : values) {
      ConcurrentMap<Data,QueryableEntry> records;
      if (value instanceof IndexImpl.NullObject) {
        records=recordsWithNullValue;
      }
 else {
        records=recordMap.get(value);
      }
      if (records != null) {
        results.addResultSet(records);
      }
    }
  }
  finally {
    releaseReadLock();
  }
}
Program: 47708
Project: 47708
Buggy source:
@Override public void removeIndex(Comparable oldValue,Data indexKey){
  takeWriteLock();
  try {
    ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(oldValue);
    if (records != null) {
      records.remove(indexKey);
      if (records.size() == 0) {
        mapRecords.remove(oldValue);
      }
    }
  }
  finally {
    releaseWriteLock();
  }
}

Fixed version (ground truth):
@Override public void removeIndex(Comparable oldValue,Data indexKey){
  takeWriteLock();
  try {
    if (oldValue instanceof IndexImpl.NullObject) {
      recordsWithNullValue.remove(indexKey);
    }
 else {
      ConcurrentMap<Data,QueryableEntry> records=recordMap.get(oldValue);
      if (records != null) {
        records.remove(indexKey);
        if (records.size() == 0) {
          recordMap.remove(oldValue);
        }
      }
    }
  }
  finally {
    releaseWriteLock();
  }
}
Program: 47709
Project: 47709
Buggy source:
@Override public void getSubRecordsBetween(MultiResultSet results,Comparable from,Comparable to){
  takeReadLock();
  try {
    Comparable paramFrom=from;
    Comparable paramTo=to;
    int trend=paramFrom.compareTo(paramTo);
    if (trend == 0) {
      ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(paramFrom);
      if (records != null) {
        results.addResultSet(records);
      }
      return;
    }
    if (trend < 0) {
      Comparable oldFrom=paramFrom;
      paramFrom=to;
      paramTo=oldFrom;
    }
    Set<Comparable> values=mapRecords.keySet();
    for (    Comparable value : values) {
      if (value.compareTo(paramFrom) <= 0 && value.compareTo(paramTo) >= 0) {
        ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(value);
        if (records != null) {
          results.addResultSet(records);
        }
      }
    }
  }
  finally {
    releaseReadLock();
  }
}

Fixed version (ground truth):
@Override public void getSubRecordsBetween(MultiResultSet results,Comparable from,Comparable to){
  takeReadLock();
  try {
    Comparable paramFrom=from;
    Comparable paramTo=to;
    int trend=paramFrom.compareTo(paramTo);
    if (trend == 0) {
      ConcurrentMap<Data,QueryableEntry> records=recordMap.get(paramFrom);
      if (records != null) {
        results.addResultSet(records);
      }
      return;
    }
    if (trend < 0) {
      Comparable oldFrom=paramFrom;
      paramFrom=to;
      paramTo=oldFrom;
    }
    Set<Comparable> values=recordMap.keySet();
    for (    Comparable value : values) {
      if (value.compareTo(paramFrom) <= 0 && value.compareTo(paramTo) >= 0) {
        ConcurrentMap<Data,QueryableEntry> records=recordMap.get(value);
        if (records != null) {
          results.addResultSet(records);
        }
      }
    }
  }
  finally {
    releaseReadLock();
  }
}
Program: 47710
Project: 47710
Buggy source:
@Override public String toString(){
  return "String_Node_Str" + "String_Node_Str" + mapRecords.size() + '}';
}

Fixed version (ground truth):
@Override public String toString(){
  return "String_Node_Str" + "String_Node_Str" + recordMap.size() + '}';
}
Program: 47711
Project: 47711
Buggy source:
@Override public void newIndex(Comparable newValue,QueryableEntry record){
  takeWriteLock();
  try {
    Data indexKey=record.getIndexKey();
    ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(newValue);
    if (records == null) {
      records=new ConcurrentHashMap<Data,QueryableEntry>();
      ConcurrentMap<Data,QueryableEntry> existing=mapRecords.putIfAbsent(newValue,records);
      if (existing != null) {
        records=existing;
      }
    }
    records.put(indexKey,record);
  }
  finally {
    releaseWriteLock();
  }
}

Fixed version (ground truth):
@Override public void newIndex(Comparable newValue,QueryableEntry record){
  takeWriteLock();
  try {
    if (newValue instanceof IndexImpl.NullObject) {
      recordsWithNullValue.put(record.getIndexKey(),record);
    }
 else {
      ConcurrentMap<Data,QueryableEntry> records=recordMap.get(newValue);
      if (records == null) {
        records=new ConcurrentHashMap<Data,QueryableEntry>(1,LOAD_FACTOR,1);
        recordMap.put(newValue,records);
      }
      records.put(record.getIndexKey(),record);
    }
  }
  finally {
    releaseWriteLock();
  }
}
Program: 47712
Project: 47712
Buggy source:
@Override public void newIndex(Comparable newValue,QueryableEntry record){
  takeWriteLock();
  try {
    if (newValue instanceof IndexImpl.NullObject) {
      recordsWithNullValue.put(record.getIndexKey(),record);
    }
 else {
      ConcurrentMap<Data,QueryableEntry> records=recordMap.get(newValue);
      if (records == null) {
        records=new ConcurrentHashMap<Data,QueryableEntry>(1,0.75f,1);
        recordMap.put(newValue,records);
      }
      records.put(record.getIndexKey(),record);
    }
  }
  finally {
    releaseWriteLock();
  }
}

Fixed version (ground truth):
@Override public void newIndex(Comparable newValue,QueryableEntry record){
  takeWriteLock();
  try {
    if (newValue instanceof IndexImpl.NullObject) {
      recordsWithNullValue.put(record.getIndexKey(),record);
    }
 else {
      ConcurrentMap<Data,QueryableEntry> records=recordMap.get(newValue);
      if (records == null) {
        records=new ConcurrentHashMap<Data,QueryableEntry>(1,LOAD_FACTOR,1);
        recordMap.put(newValue,records);
      }
      records.put(record.getIndexKey(),record);
    }
  }
  finally {
    releaseWriteLock();
  }
}
Program: 47713
Project: 47713
Buggy source:
@Test(timeout=30000) public void testSemaphoreWithFailures() throws InterruptedException {
  final int k=4;
  TestHazelcastInstanceFactory factory=createHazelcastInstanceFactory(k + 1);
  final HazelcastInstance[] instances=factory.newInstances();
  final ISemaphore semaphore=instances[k].getSemaphore("String_Node_Str");
  int initialPermits=20;
  semaphore.init(initialPermits);
  for (int i=0; i < k; i++) {
    int rand=(int)(Math.random() * 5) + 1;
    semaphore.acquire(rand);
    initialPermits-=rand;
    assertEquals(initialPermits,semaphore.availablePermits());
    semaphore.release(rand);
    initialPermits+=rand;
    assertEquals(initialPermits,semaphore.availablePermits());
    instances[i].getLifecycleService().shutdown();
    semaphore.acquire(rand);
    initialPermits-=rand;
    assertEquals(initialPermits,semaphore.availablePermits());
    semaphore.release(rand);
    initialPermits+=rand;
    assertEquals(initialPermits,semaphore.availablePermits());
  }
}

Fixed version (ground truth):
@Test(timeout=120000) public void testSemaphoreWithFailures() throws InterruptedException {
  final int k=4;
  final TestHazelcastInstanceFactory factory=createHazelcastInstanceFactory(k + 1);
  final HazelcastInstance[] instances=factory.newInstances();
  final ISemaphore semaphore=instances[k].getSemaphore("String_Node_Str");
  int initialPermits=20;
  semaphore.init(initialPermits);
  for (int i=0; i < k; i++) {
    int rand=(int)(Math.random() * 5) + 1;
    semaphore.acquire(rand);
    initialPermits-=rand;
    assertEquals(initialPermits,semaphore.availablePermits());
    semaphore.release(rand);
    initialPermits+=rand;
    assertEquals(initialPermits,semaphore.availablePermits());
    instances[i].shutdown();
    semaphore.acquire(rand);
    initialPermits-=rand;
    assertEquals(initialPermits,semaphore.availablePermits());
    semaphore.release(rand);
    initialPermits+=rand;
    assertEquals(initialPermits,semaphore.availablePermits());
  }
}
Program: 47714
Project: 47714
Buggy source:
@Test(timeout=30000) public void testSemaphoreWithFailuresAndJoin(){
  final TestHazelcastInstanceFactory factory=createHazelcastInstanceFactory(3);
  final HazelcastInstance instance1=factory.newHazelcastInstance();
  final HazelcastInstance instance2=factory.newHazelcastInstance();
  final ISemaphore semaphore=instance1.getSemaphore("String_Node_Str");
  final CountDownLatch countDownLatch=new CountDownLatch(1);
  assertTrue(semaphore.init(0));
  final Thread thread=new Thread(){
    public void run(){
      for (int i=0; i < 2; i++) {
        try {
          semaphore.acquire();
        }
 catch (        InterruptedException e) {
          e.printStackTrace();
        }
      }
      countDownLatch.countDown();
    }
  }
;
  thread.start();
  instance2.getLifecycleService().shutdown();
  semaphore.release();
  HazelcastInstance instance3=factory.newHazelcastInstance();
  ISemaphore semaphore1=instance3.getSemaphore("String_Node_Str");
  semaphore1.release();
  try {
    assertTrue(countDownLatch.await(15,TimeUnit.SECONDS));
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
 finally {
    thread.interrupt();
  }
}

Fixed version (ground truth):
@Test(timeout=120000) public void testSemaphoreWithFailuresAndJoin(){
  final TestHazelcastInstanceFactory factory=createHazelcastInstanceFactory(3);
  final HazelcastInstance instance1=factory.newHazelcastInstance();
  final HazelcastInstance instance2=factory.newHazelcastInstance();
  final ISemaphore semaphore=instance1.getSemaphore("String_Node_Str");
  final CountDownLatch countDownLatch=new CountDownLatch(1);
  assertTrue(semaphore.init(0));
  final Thread thread=new Thread(){
    public void run(){
      for (int i=0; i < 2; i++) {
        try {
          semaphore.acquire();
        }
 catch (        InterruptedException e) {
          e.printStackTrace();
        }
      }
      countDownLatch.countDown();
    }
  }
;
  thread.start();
  instance2.shutdown();
  semaphore.release();
  HazelcastInstance instance3=factory.newHazelcastInstance();
  ISemaphore semaphore1=instance3.getSemaphore("String_Node_Str");
  semaphore1.release();
  try {
    assertTrue(countDownLatch.await(15,TimeUnit.SECONDS));
  }
 catch (  InterruptedException e) {
    e.printStackTrace();
  }
 finally {
    thread.interrupt();
  }
}
Program: 47715
Project: 47715
Buggy source:
@Test(timeout=30000) public void testMutex() throws InterruptedException {
  final int threadCount=2;
  final HazelcastInstance[] instances=createHazelcastInstanceFactory(threadCount).newInstances();
  final CountDownLatch latch=new CountDownLatch(threadCount);
  final int loopCount=1000;
class Counter {
    int count=0;
    void inc(){
      count++;
    }
    int get(){
      return count;
    }
  }
  final Counter counter=new Counter();
  assertTrue(instances[0].getSemaphore("String_Node_Str").init(1));
  for (int i=0; i < threadCount; i++) {
    final ISemaphore semaphore=instances[i].getSemaphore("String_Node_Str");
    new Thread(){
      public void run(){
        for (int j=0; j < loopCount; j++) {
          try {
            semaphore.acquire();
            sleepMillis((int)(Math.random() * 3));
            counter.inc();
          }
 catch (          InterruptedException e) {
            return;
          }
 finally {
            semaphore.release();
          }
        }
        latch.countDown();
      }
    }
.start();
  }
  assertOpenEventually(latch);
  assertEquals(loopCount * threadCount,counter.get());
}

Fixed version (ground truth):
@Test(timeout=120000) public void testMutex() throws InterruptedException {
  final int threadCount=2;
  final HazelcastInstance[] instances=createHazelcastInstanceFactory(threadCount).newInstances();
  final CountDownLatch latch=new CountDownLatch(threadCount);
  final int loopCount=1000;
class Counter {
    int count=0;
    void inc(){
      count++;
    }
    int get(){
      return count;
    }
  }
  final Counter counter=new Counter();
  assertTrue(instances[0].getSemaphore("String_Node_Str").init(1));
  for (int i=0; i < threadCount; i++) {
    final ISemaphore semaphore=instances[i].getSemaphore("String_Node_Str");
    new Thread(){
      public void run(){
        for (int j=0; j < loopCount; j++) {
          try {
            semaphore.acquire();
            sleepMillis((int)(Math.random() * 3));
            counter.inc();
          }
 catch (          InterruptedException e) {
            return;
          }
 finally {
            semaphore.release();
          }
        }
        latch.countDown();
      }
    }
.start();
  }
  assertOpenEventually(latch);
  assertEquals(loopCount * threadCount,counter.get());
}
Program: 47716
Project: 47716
Buggy source:
@Override public void updateIndex(Comparable oldValue,Comparable newValue,QueryableEntry entry){
  ensureNotLocked();
  takeLock();
  try {
    removeIndex(oldValue,entry.getIndexKey());
    newIndex(newValue,entry);
  }
  finally {
    releaseLock();
  }
}

Fixed version (ground truth):
@Override public void updateIndex(Comparable oldValue,Comparable newValue,QueryableEntry entry){
  takeWriteLock();
  try {
    removeIndex(oldValue,entry.getIndexKey());
    newIndex(newValue,entry);
  }
  finally {
    releaseWriteLock();
  }
}
Program: 47717
Project: 47717
Buggy source:
@Override public void getSubRecords(MultiResultSet results,ComparisonType comparisonType,Comparable searchedValue){
  ensureNotLocked();
  readerCount.incrementAndGet();
  try {
    Set<Comparable> values;
    boolean notEqual=false;
switch (comparisonType) {
case LESSER:
      values=sortedSet.headSet(searchedValue,false);
    break;
case LESSER_EQUAL:
  values=sortedSet.headSet(searchedValue,true);
break;
case GREATER:
values=sortedSet.tailSet(searchedValue,false);
break;
case GREATER_EQUAL:
values=sortedSet.tailSet(searchedValue,true);
break;
case NOT_EQUAL:
values=sortedSet;
notEqual=true;
break;
default :
throw new IllegalArgumentException("String_Node_Str" + comparisonType);
}
for (Comparable value : values) {
if (notEqual && searchedValue.equals(value)) {
continue;
}
ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(value);
if (records != null) {
results.addResultSet(records);
}
}
}
  finally {
readerCount.decrementAndGet();
}
}

Fixed version (ground truth):
@Override public void getSubRecords(MultiResultSet results,ComparisonType comparisonType,Comparable searchedValue){
  takeReadLock();
  try {
    Set<Comparable> values;
    boolean notEqual=false;
switch (comparisonType) {
case LESSER:
      values=sortedSet.headSet(searchedValue,false);
    break;
case LESSER_EQUAL:
  values=sortedSet.headSet(searchedValue,true);
break;
case GREATER:
values=sortedSet.tailSet(searchedValue,false);
break;
case GREATER_EQUAL:
values=sortedSet.tailSet(searchedValue,true);
break;
case NOT_EQUAL:
values=sortedSet;
notEqual=true;
break;
default :
throw new IllegalArgumentException("String_Node_Str" + comparisonType);
}
for (Comparable value : values) {
if (notEqual && searchedValue.equals(value)) {
continue;
}
ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(value);
if (records != null) {
results.addResultSet(records);
}
}
}
  finally {
releaseReadLock();
}
}
Program: 47718
Project: 47718
Buggy source:
@Override public ConcurrentMap<Data,QueryableEntry> getRecordMap(Comparable indexValue){
  ensureNotLocked();
  readerCount.incrementAndGet();
  try {
    return mapRecords.get(indexValue);
  }
  finally {
    readerCount.decrementAndGet();
  }
}

Fixed version (ground truth):
@Override public ConcurrentMap<Data,QueryableEntry> getRecordMap(Comparable indexValue){
  takeReadLock();
  try {
    return mapRecords.get(indexValue);
  }
  finally {
    releaseReadLock();
  }
}
Program: 47719
Project: 47719
Buggy source:
@Override public void clear(){
  ensureNotLocked();
  takeLock();
  try {
    mapRecords.clear();
    sortedSet.clear();
  }
  finally {
    releaseLock();
  }
}

Fixed version (ground truth):
@Override public void clear(){
  takeWriteLock();
  try {
    mapRecords.clear();
    sortedSet.clear();
  }
  finally {
    releaseWriteLock();
  }
}
Program: 47720
Project: 47720
Buggy source:
@Override public void getRecords(MultiResultSet results,Set<Comparable> values){
  ensureNotLocked();
  readerCount.incrementAndGet();
  try {
    for (    Comparable value : values) {
      ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(value);
      if (records != null) {
        results.addResultSet(records);
      }
    }
  }
  finally {
    readerCount.decrementAndGet();
  }
}

Fixed version (ground truth):
@Override public void getRecords(MultiResultSet results,Set<Comparable> values){
  takeReadLock();
  try {
    for (    Comparable value : values) {
      ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(value);
      if (records != null) {
        results.addResultSet(records);
      }
    }
  }
  finally {
    releaseReadLock();
  }
}
Program: 47721
Project: 47721
Buggy source:
@Override public void removeIndex(Comparable oldValue,Data indexKey){
  ensureNotLocked();
  takeLock();
  try {
    ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(oldValue);
    if (records != null) {
      records.remove(indexKey);
      if (records.size() == 0) {
        mapRecords.remove(oldValue);
        sortedSet.remove(oldValue);
      }
    }
  }
  finally {
    releaseLock();
  }
}

Fixed version (ground truth):
@Override public void removeIndex(Comparable oldValue,Data indexKey){
  takeWriteLock();
  try {
    ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(oldValue);
    if (records != null) {
      records.remove(indexKey);
      if (records.size() == 0) {
        mapRecords.remove(oldValue);
        sortedSet.remove(oldValue);
      }
    }
  }
  finally {
    releaseWriteLock();
  }
}
Program: 47722
Project: 47722
Buggy source:
@Override public void getSubRecordsBetween(MultiResultSet results,Comparable from,Comparable to){
  ensureNotLocked();
  readerCount.incrementAndGet();
  try {
    Set<Comparable> values=sortedSet.subSet(from,to);
    for (    Comparable value : values) {
      ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(value);
      if (records != null) {
        results.addResultSet(records);
      }
    }
    ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(to);
    if (records != null) {
      results.addResultSet(records);
    }
  }
  finally {
    readerCount.decrementAndGet();
  }
}

Fixed version (ground truth):
@Override public void getSubRecordsBetween(MultiResultSet results,Comparable from,Comparable to){
  takeReadLock();
  try {
    Set<Comparable> values=sortedSet.subSet(from,to);
    for (    Comparable value : values) {
      ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(value);
      if (records != null) {
        results.addResultSet(records);
      }
    }
    ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(to);
    if (records != null) {
      results.addResultSet(records);
    }
  }
  finally {
    releaseReadLock();
  }
}
Program: 47723
Project: 47723
Buggy source:
@Override public void newIndex(Comparable newValue,QueryableEntry record){
  ensureNotLocked();
  takeLock();
  try {
    ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(newValue);
    if (records == null) {
      records=new ConcurrentHashMap<Data,QueryableEntry>(1,LOAD_FACTOR,1);
      mapRecords.put(newValue,records);
      if (!(newValue instanceof IndexImpl.NullObject)) {
        sortedSet.add(newValue);
      }
    }
    records.put(record.getIndexKey(),record);
  }
  finally {
    releaseLock();
  }
}

Fixed version (ground truth):
@Override public void newIndex(Comparable newValue,QueryableEntry record){
  takeWriteLock();
  try {
    ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(newValue);
    if (records == null) {
      records=new ConcurrentHashMap<Data,QueryableEntry>(1,LOAD_FACTOR,1);
      mapRecords.put(newValue,records);
      if (!(newValue instanceof IndexImpl.NullObject)) {
        sortedSet.add(newValue);
      }
    }
    records.put(record.getIndexKey(),record);
  }
  finally {
    releaseWriteLock();
  }
}
Program: 47724
Project: 47724
Buggy source:
@Override public void updateIndex(Comparable oldValue,Comparable newValue,QueryableEntry entry){
  ensureNotLocked();
  takeLock();
  try {
    removeIndex(oldValue,entry.getIndexKey());
    newIndex(newValue,entry);
  }
  finally {
    releaseLock();
  }
}

Fixed version (ground truth):
@Override public void updateIndex(Comparable oldValue,Comparable newValue,QueryableEntry entry){
  takeWriteLock();
  try {
    removeIndex(oldValue,entry.getIndexKey());
    newIndex(newValue,entry);
  }
  finally {
    releaseWriteLock();
  }
}
Program: 47725
Project: 47725
Buggy source:
@Override public void getSubRecords(MultiResultSet results,ComparisonType comparisonType,Comparable searchedValue){
  ensureNotLocked();
  readerCount.incrementAndGet();
  try {
    Set<Comparable> values=mapRecords.keySet();
    for (    Comparable value : values) {
      boolean valid;
      int result=value.compareTo(searchedValue);
switch (comparisonType) {
case LESSER:
        valid=result < 0;
      break;
case LESSER_EQUAL:
    valid=result <= 0;
  break;
case GREATER:
valid=result > 0;
break;
case GREATER_EQUAL:
valid=result >= 0;
break;
case NOT_EQUAL:
valid=result != 0;
break;
default :
throw new IllegalStateException("String_Node_Str" + comparisonType);
}
if (valid) {
ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(value);
if (records != null) {
results.addResultSet(records);
}
}
}
}
  finally {
readerCount.decrementAndGet();
}
}

Fixed version (ground truth):
@Override public void getSubRecords(MultiResultSet results,ComparisonType comparisonType,Comparable searchedValue){
  takeReadLock();
  try {
    Set<Comparable> values=mapRecords.keySet();
    for (    Comparable value : values) {
      boolean valid;
      int result=value.compareTo(searchedValue);
switch (comparisonType) {
case LESSER:
        valid=result < 0;
      break;
case LESSER_EQUAL:
    valid=result <= 0;
  break;
case GREATER:
valid=result > 0;
break;
case GREATER_EQUAL:
valid=result >= 0;
break;
case NOT_EQUAL:
valid=result != 0;
break;
default :
throw new IllegalStateException("String_Node_Str" + comparisonType);
}
if (valid) {
ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(value);
if (records != null) {
results.addResultSet(records);
}
}
}
}
  finally {
releaseReadLock();
}
}
Program: 47726
Project: 47726
Buggy source:
@Override public ConcurrentMap<Data,QueryableEntry> getRecordMap(Comparable indexValue){
  ensureNotLocked();
  readerCount.incrementAndGet();
  try {
    return mapRecords.get(indexValue);
  }
  finally {
    readerCount.decrementAndGet();
  }
}

Fixed version (ground truth):
@Override public ConcurrentMap<Data,QueryableEntry> getRecordMap(Comparable indexValue){
  takeReadLock();
  try {
    return mapRecords.get(indexValue);
  }
  finally {
    releaseReadLock();
  }
}
Program: 47727
Project: 47727
Buggy source:
@Override public void clear(){
  ensureNotLocked();
  takeLock();
  try {
    mapRecords.clear();
  }
  finally {
    releaseLock();
  }
}

Fixed version (ground truth):
@Override public void clear(){
  takeWriteLock();
  try {
    mapRecords.clear();
  }
  finally {
    releaseWriteLock();
  }
}
Program: 47728
Project: 47728
Buggy source:
@Override public void getRecords(MultiResultSet results,Set<Comparable> values){
  ensureNotLocked();
  readerCount.incrementAndGet();
  try {
    for (    Comparable value : values) {
      ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(value);
      if (records != null) {
        results.addResultSet(records);
      }
    }
  }
  finally {
    readerCount.decrementAndGet();
  }
}

Fixed version (ground truth):
@Override public void getRecords(MultiResultSet results,Set<Comparable> values){
  takeReadLock();
  try {
    for (    Comparable value : values) {
      ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(value);
      if (records != null) {
        results.addResultSet(records);
      }
    }
  }
  finally {
    releaseReadLock();
  }
}
Program: 47729
Project: 47729
Buggy source:
@Override public void removeIndex(Comparable oldValue,Data indexKey){
  ensureNotLocked();
  takeLock();
  try {
    ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(oldValue);
    if (records != null) {
      records.remove(indexKey);
      if (records.size() == 0) {
        mapRecords.remove(oldValue);
      }
    }
  }
  finally {
    releaseLock();
  }
}

Fixed version (ground truth):
@Override public void removeIndex(Comparable oldValue,Data indexKey){
  takeWriteLock();
  try {
    ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(oldValue);
    if (records != null) {
      records.remove(indexKey);
      if (records.size() == 0) {
        mapRecords.remove(oldValue);
      }
    }
  }
  finally {
    releaseWriteLock();
  }
}
Program: 47730
Project: 47730
Buggy source:
@Override public void getSubRecordsBetween(MultiResultSet results,Comparable from,Comparable to){
  ensureNotLocked();
  readerCount.incrementAndGet();
  try {
    Comparable paramFrom=from;
    Comparable paramTo=to;
    int trend=paramFrom.compareTo(paramTo);
    if (trend == 0) {
      ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(paramFrom);
      if (records != null) {
        results.addResultSet(records);
      }
      return;
    }
    if (trend < 0) {
      Comparable oldFrom=paramFrom;
      paramFrom=to;
      paramTo=oldFrom;
    }
    Set<Comparable> values=mapRecords.keySet();
    for (    Comparable value : values) {
      if (value.compareTo(paramFrom) <= 0 && value.compareTo(paramTo) >= 0) {
        ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(value);
        if (records != null) {
          results.addResultSet(records);
        }
      }
    }
  }
  finally {
    readerCount.decrementAndGet();
  }
}

Fixed version (ground truth):
@Override public void getSubRecordsBetween(MultiResultSet results,Comparable from,Comparable to){
  takeReadLock();
  try {
    Comparable paramFrom=from;
    Comparable paramTo=to;
    int trend=paramFrom.compareTo(paramTo);
    if (trend == 0) {
      ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(paramFrom);
      if (records != null) {
        results.addResultSet(records);
      }
      return;
    }
    if (trend < 0) {
      Comparable oldFrom=paramFrom;
      paramFrom=to;
      paramTo=oldFrom;
    }
    Set<Comparable> values=mapRecords.keySet();
    for (    Comparable value : values) {
      if (value.compareTo(paramFrom) <= 0 && value.compareTo(paramTo) >= 0) {
        ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(value);
        if (records != null) {
          results.addResultSet(records);
        }
      }
    }
  }
  finally {
    releaseReadLock();
  }
}
Program: 47731
Project: 47731
Buggy source:
@Override public void newIndex(Comparable newValue,QueryableEntry record){
  ensureNotLocked();
  takeLock();
  try {
    Data indexKey=record.getIndexKey();
    ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(newValue);
    if (records == null) {
      records=new ConcurrentHashMap<Data,QueryableEntry>();
      ConcurrentMap<Data,QueryableEntry> existing=mapRecords.putIfAbsent(newValue,records);
      if (existing != null) {
        records=existing;
      }
    }
    records.put(indexKey,record);
  }
  finally {
    releaseLock();
  }
}

Fixed version (ground truth):
@Override public void newIndex(Comparable newValue,QueryableEntry record){
  takeWriteLock();
  try {
    Data indexKey=record.getIndexKey();
    ConcurrentMap<Data,QueryableEntry> records=mapRecords.get(newValue);
    if (records == null) {
      records=new ConcurrentHashMap<Data,QueryableEntry>();
      ConcurrentMap<Data,QueryableEntry> existing=mapRecords.putIfAbsent(newValue,records);
      if (existing != null) {
        records=existing;
      }
    }
    records.put(indexKey,record);
  }
  finally {
    releaseWriteLock();
  }
}
Program: 47732
Project: 47732
Buggy source:
@Override public void updateIndex(Comparable oldValue,Comparable newValue,QueryableEntry entry){
  if (oldValue.equals(newValue)) {
    return;
  }
  ensureNotLocked();
  takeLock();
  try {
    removeIndex(oldValue,entry.getIndexKey());
    newIndex(newValue,entry);
  }
  finally {
    releaseLock();
  }
}

Fixed version (ground truth):
@Override public void updateIndex(Comparable oldValue,Comparable newValue,QueryableEntry entry){
  ensureNotLocked();
  takeLock();
  try {
    removeIndex(oldValue,entry.getIndexKey());
    newIndex(newValue,entry);
  }
  finally {
    releaseLock();
  }
}
Program: 47733
Project: 47733
Buggy source:
@Override public Set<QueryableEntry> getSubRecords(ComparisonType comparisonType,Comparable searchedValue){
  beforeRead();
  try {
    MultiResultSet results=new MultiResultSet();
    if (attributeType != null) {
      indexStore.getSubRecords(results,comparisonType,convert(searchedValue));
    }
    return results;
  }
  finally {
    afterRead();
  }
}

Fixed version (ground truth):
@Override public Set<QueryableEntry> getSubRecords(ComparisonType comparisonType,Comparable searchedValue){
  MultiResultSet results=new MultiResultSet();
  if (attributeType != null) {
    indexStore.getSubRecords(results,comparisonType,convert(searchedValue));
  }
  return results;
}
Program: 47734
Project: 47734
Buggy source:
@Override public synchronized void saveEntryIndex(QueryableEntry e) throws QueryException {
  beforeWrite();
  try {
    if (attributeType == null) {
      attributeType=e.getAttributeType(attribute);
    }
    Data key=e.getIndexKey();
    Comparable oldValue=recordValues.remove(key);
    Comparable newValue=e.getAttribute(attribute);
    if (newValue == null) {
      newValue=NULL;
    }
 else     if (newValue.getClass().isEnum()) {
      newValue=TypeConverters.ENUM_CONVERTER.convert(newValue);
    }
    recordValues.put(key,newValue);
    if (oldValue == null) {
      indexStore.newIndex(newValue,e);
    }
 else {
      indexStore.removeIndex(oldValue,key);
      indexStore.newIndex(newValue,e);
    }
  }
  finally {
    afterWrite();
  }
}

Fixed version (ground truth):
@Override public void saveEntryIndex(QueryableEntry e) throws QueryException {
  if (attributeType == null) {
    attributeType=e.getAttributeType(attribute);
  }
  Data key=e.getIndexKey();
  Comparable oldValue=recordValues.remove(key);
  Comparable newValue=e.getAttribute(attribute);
  if (newValue == null) {
    newValue=NULL;
  }
 else   if (newValue.getClass().isEnum()) {
    newValue=TypeConverters.ENUM_CONVERTER.convert(newValue);
  }
  recordValues.put(key,newValue);
  if (oldValue == null) {
    indexStore.newIndex(newValue,e);
  }
 else {
    indexStore.updateIndex(oldValue,newValue,e);
  }
}
Program: 47735
Project: 47735
Buggy source:
@Override public Set<QueryableEntry> getRecords(Comparable value){
  beforeRead();
  try {
    if (attributeType != null) {
      return indexStore.getRecords(convert(value));
    }
 else {
      return new SingleResultSet(null);
    }
  }
  finally {
    afterRead();
  }
}

Fixed version (ground truth):
@Override public Set<QueryableEntry> getRecords(Comparable value){
  if (attributeType != null) {
    return indexStore.getRecords(convert(value));
  }
 else {
    return new SingleResultSet(null);
  }
}
Program: 47736
Project: 47736
Buggy source:
@Override public Set<QueryableEntry> getSubRecordsBetween(Comparable from,Comparable to){
  beforeRead();
  try {
    MultiResultSet results=new MultiResultSet();
    if (attributeType != null) {
      indexStore.getSubRecordsBetween(results,convert(from),convert(to));
    }
    return results;
  }
  finally {
    afterRead();
  }
}

Fixed version (ground truth):
@Override public Set<QueryableEntry> getSubRecordsBetween(Comparable from,Comparable to){
  MultiResultSet results=new MultiResultSet();
  if (attributeType != null) {
    indexStore.getSubRecordsBetween(results,convert(from),convert(to));
  }
  return results;
}
Program: 47737
Project: 47737
Buggy source:
@Override public Set<QueryableEntry> getSubRecords(ComparisonType comparisonType,Comparable searchedValue){
  MultiResultSet results=new MultiResultSet();
  if (attributeType != null) {
    indexStore.getSubRecords(results,comparisonType,convert(searchedValue));
  }
  return results;
}

Fixed version (ground truth):
@Override public Set<QueryableEntry> getSubRecords(ComparisonType comparisonType,Comparable searchedValue){
  beforeRead();
  try {
    MultiResultSet results=new MultiResultSet();
    if (attributeType != null) {
      indexStore.getSubRecords(results,comparisonType,convert(searchedValue));
    }
    return results;
  }
  finally {
    afterRead();
  }
}
Program: 47738
Project: 47738
Buggy source:
@Override public void saveEntryIndex(QueryableEntry e) throws QueryException {
  if (attributeType == null) {
    attributeType=e.getAttributeType(attribute);
  }
  Data key=e.getIndexKey();
  Comparable oldValue=recordValues.remove(key);
  Comparable newValue=e.getAttribute(attribute);
  if (newValue == null) {
    newValue=NULL;
  }
 else   if (newValue.getClass().isEnum()) {
    newValue=TypeConverters.ENUM_CONVERTER.convert(newValue);
  }
  recordValues.put(key,newValue);
  if (oldValue == null) {
    indexStore.newIndex(newValue,e);
  }
 else {
    indexStore.removeIndex(oldValue,key);
    indexStore.newIndex(newValue,e);
  }
}

Fixed version (ground truth):
@Override public synchronized void saveEntryIndex(QueryableEntry e) throws QueryException {
  beforeWrite();
  try {
    if (attributeType == null) {
      attributeType=e.getAttributeType(attribute);
    }
    Data key=e.getIndexKey();
    Comparable oldValue=recordValues.remove(key);
    Comparable newValue=e.getAttribute(attribute);
    if (newValue == null) {
      newValue=NULL;
    }
 else     if (newValue.getClass().isEnum()) {
      newValue=TypeConverters.ENUM_CONVERTER.convert(newValue);
    }
    recordValues.put(key,newValue);
    if (oldValue == null) {
      indexStore.newIndex(newValue,e);
    }
 else {
      indexStore.removeIndex(oldValue,key);
      indexStore.newIndex(newValue,e);
    }
  }
  finally {
    afterWrite();
  }
}
Program: 47739
Project: 47739
Buggy source:
@Override public Set<QueryableEntry> getRecords(Comparable value){
  if (attributeType != null) {
    return indexStore.getRecords(convert(value));
  }
 else {
    return new SingleResultSet(null);
  }
}

Fixed version (ground truth):
@Override public Set<QueryableEntry> getRecords(Comparable value){
  beforeRead();
  try {
    if (attributeType != null) {
      return indexStore.getRecords(convert(value));
    }
 else {
      return new SingleResultSet(null);
    }
  }
  finally {
    afterRead();
  }
}
Program: 47740
Project: 47740
Buggy source:
@Override public Set<QueryableEntry> getSubRecordsBetween(Comparable from,Comparable to){
  MultiResultSet results=new MultiResultSet();
  if (attributeType != null) {
    indexStore.getSubRecordsBetween(results,convert(from),convert(to));
  }
  return results;
}

Fixed version (ground truth):
@Override public Set<QueryableEntry> getSubRecordsBetween(Comparable from,Comparable to){
  beforeRead();
  try {
    MultiResultSet results=new MultiResultSet();
    if (attributeType != null) {
      indexStore.getSubRecordsBetween(results,convert(from),convert(to));
    }
    return results;
  }
  finally {
    afterRead();
  }
}