Program: 47939
Project: 47939
Buggy source:
/** 
 * Gets the requested version of the record (fields and recordTypes) from the Result object.
 */
public Record decodeRecord(RecordId recordId,Long requestedVersion,ReadContext readContext,Result result,FieldTypes fieldTypes) throws InterruptedException, RepositoryException {
  Record record=newRecord(recordId);
  record.setVersion(requestedVersion);
  Set<Scope> scopes=EnumSet.noneOf(Scope.class);
  Long versionToRead=(requestedVersion == null) ? 1L : requestedVersion;
  NavigableMap<byte[],NavigableMap<Long,byte[]>> mapWithVersions=result.getMap().get(RecordCf.DATA.bytes);
  if (mapWithVersions != null) {
    for (    Map.Entry<byte[],NavigableMap<Long,byte[]>> columnWithAllVersions : mapWithVersions.entrySet()) {
      byte[] key=columnWithAllVersions.getKey();
      if (key[0] == LilyHBaseSchema.RecordColumn.DATA_PREFIX) {
        NavigableMap<Long,byte[]> allValueVersions=columnWithAllVersions.getValue();
        Map.Entry<Long,byte[]> ceilingEntry=allValueVersions.ceilingEntry(versionToRead);
        if (ceilingEntry != null) {
          Pair<FieldType,Object> field=extractField(key,ceilingEntry.getValue(),readContext,fieldTypes);
          if (field != null) {
            record.setField(field.getV1().getName(),field.getV2());
            scopes.add(field.getV1().getScope());
          }
        }
      }
    }
  }
  if (!scopes.isEmpty()) {
    if (requestedVersion == null) {
      Pair<SchemaId,Long> recordTypePair=extractLatestRecordType(Scope.NON_VERSIONED,result);
      if (recordTypePair != null) {
        RecordType recordType=typeManager.getRecordTypeById(recordTypePair.getV1(),recordTypePair.getV2());
        record.setRecordType(recordType.getName(),recordType.getVersion());
        if (readContext != null)         readContext.setRecordTypeId(Scope.NON_VERSIONED,recordType);
      }
    }
 else {
      scopes.add(Scope.NON_VERSIONED);
      for (      Scope scope : scopes) {
        Pair<SchemaId,Long> recordTypePair=extractVersionRecordType(scope,result,requestedVersion);
        if (recordTypePair != null) {
          RecordType recordType=typeManager.getRecordTypeById(recordTypePair.getV1(),recordTypePair.getV2());
          record.setRecordType(scope,recordType.getName(),recordType.getVersion());
          if (readContext != null)           readContext.setRecordTypeId(scope,recordType);
        }
      }
    }
  }
  return record;
}

Fixed version (ground truth):
/** 
 * Gets the requested version of the record (fields and recordTypes) from the Result object.
 */
public Record decodeRecord(RecordId recordId,Long requestedVersion,ReadContext readContext,Result result,FieldTypes fieldTypes) throws InterruptedException, RepositoryException {
  Record record=newRecord(recordId);
  record.setVersion(requestedVersion);
  Long versionToRead=(requestedVersion == null) ? 1L : requestedVersion;
  NavigableMap<byte[],NavigableMap<Long,byte[]>> mapWithVersions=result.getMap().get(RecordCf.DATA.bytes);
  if (mapWithVersions != null) {
    for (    Map.Entry<byte[],NavigableMap<Long,byte[]>> columnWithAllVersions : mapWithVersions.entrySet()) {
      byte[] key=columnWithAllVersions.getKey();
      if (key[0] == LilyHBaseSchema.RecordColumn.DATA_PREFIX) {
        NavigableMap<Long,byte[]> allValueVersions=columnWithAllVersions.getValue();
        Map.Entry<Long,byte[]> ceilingEntry=allValueVersions.ceilingEntry(versionToRead);
        if (ceilingEntry != null) {
          Pair<FieldType,Object> field=extractField(key,ceilingEntry.getValue(),readContext,fieldTypes);
          if (field != null) {
            record.setField(field.getV1().getName(),field.getV2());
          }
        }
      }
    }
  }
  for (  Scope scope : Scope.values()) {
    Pair<SchemaId,Long> recordTypePair=requestedVersion == null ? extractLatestRecordType(scope,result) : extractVersionRecordType(scope,result,requestedVersion);
    if (recordTypePair != null) {
      RecordType recordType=typeManager.getRecordTypeById(recordTypePair.getV1(),recordTypePair.getV2());
      record.setRecordType(scope,recordType.getName(),recordType.getVersion());
      if (readContext != null)       readContext.setRecordTypeId(scope,recordType);
    }
  }
  return record;
}