nus-yam/ex-repair huggingface dataset:
Program: 62025
Project: 62025
Buggy source:
@Test public void testInsert() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  ValueInsertionResult expected=new ValueInsertionResult(DATA_HUB_KEY,null,null);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  ValueInsertionResult result=testClass.write(CHANNEL_NAME,value,0);
  assertEquals(expected,result);
  verify(mutator).insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column);
}

Fixed version (ground truth):
@Test public void testInsert() throws Exception {
  DataHubCompositeValue value=new DataHubCompositeValue(CONTENT_TYPE,CONTENT_LANGUAGE,DATA,0L);
  ValueInsertionResult expected=new ValueInsertionResult(DATA_HUB_KEY,null,null);
  String columnName=keyRenderer.keyToString(DATA_HUB_KEY);
  when(hector.createColumn(columnName,value,0,StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(column);
  when(rowStrategy.buildKey(CHANNEL_NAME,DATA_HUB_KEY)).thenReturn(ROW_KEY);
  when(keyGenerator.newKey(CHANNEL_NAME)).thenReturn(DATA_HUB_KEY);
  CassandraValueWriter testClass=new CassandraValueWriter(connector,hector,rowStrategy,keyGenerator,keyRenderer,mock(TimeProvider.class));
  ValueInsertionResult result=testClass.write(CHANNEL_NAME,value,Optional.of(0));
  assertEquals(expected,result);
  verify(mutator).insert(ROW_KEY,DATA_HUB_COLUMN_FAMILY_NAME,column);
}
Program: 62026
Project: 62026
Buggy source:
@Override public String prevKey(String channelName,String currentRowKey){
  DateTime date=formatter.parseDateTime(currentRowKey);
  date=date.minusDays(1);
  return addPrefix(channelName,formatter.print(date.getMillis()));
}

Fixed version (ground truth):
@Override public String prevKey(String channelName,String currentRowKey){
  String datePart=stripPrefix(channelName,currentRowKey);
  DateTime date=formatter.parseDateTime(datePart);
  date=date.minusHours(1);
  return addPrefix(channelName,formatter.print(date.getMillis()));
}
Program: 62027
Project: 62027
Buggy source:
@Override public String nextKey(String channelName,String currentRowKey){
  DateTime date=formatter.parseDateTime(currentRowKey);
  date=date.plusDays(1);
  return addPrefix(channelName,formatter.print(date.getMillis()));
}

Fixed version (ground truth):
@Override public String nextKey(String channelName,String currentRowKey){
  String datePart=stripPrefix(channelName,currentRowKey);
  DateTime date=formatter.parseDateTime(datePart);
  date=date.plusHours(1);
  return addPrefix(channelName,formatter.print(date.getMillis()));
}
Program: 62028
Project: 62028
Buggy source:
@Override public String prevKey(String channelName,String currentRowKey){
  DateTime date=formatter.parseDateTime(currentRowKey);
  date=date.minusDays(1);
  return addPrefix(channelName,formatter.print(date.getMillis()));
}

Fixed version (ground truth):
@Override public String prevKey(String channelName,String currentRowKey){
  String datePart=stripPrefix(channelName,currentRowKey);
  DateTime date=formatter.parseDateTime(datePart);
  date=date.minusHours(1);
  return addPrefix(channelName,formatter.print(date.getMillis()));
}
Program: 62029
Project: 62029
Buggy source:
@Override public String nextKey(String channelName,String currentRowKey){
  DateTime date=formatter.parseDateTime(currentRowKey);
  date=date.plusDays(1);
  return addPrefix(channelName,formatter.print(date.getMillis()));
}

Fixed version (ground truth):
@Override public String nextKey(String channelName,String currentRowKey){
  String datePart=stripPrefix(channelName,currentRowKey);
  DateTime date=formatter.parseDateTime(datePart);
  date=date.plusHours(1);
  return addPrefix(channelName,formatter.print(date.getMillis()));
}
Program: 62030
Project: 62030
Buggy source:
private Optional<DataHubKey> findFirstDifferentResult(DataHubKey inputKey,QueryResult<OrderedRows<String,String,DataHubCompositeValue>> queryResult,final boolean reversed){
  OrderedRows<String,String,DataHubCompositeValue> rows=queryResult.get();
  Iterable<Row<String,String,DataHubCompositeValue>> nonLatestRows=excludeLatestChannelItemRow(rows.getList());
  List<Row<String,String,DataHubCompositeValue>> sortedRows=getSortedRows(reversed,nonLatestRows);
  String inputKeyString=keyRenderer.keyToString(inputKey);
  for (  Row<String,String,DataHubCompositeValue> row : sortedRows) {
    ColumnSlice<String,DataHubCompositeValue> columnSlice=row.getColumnSlice();
    Optional<DataHubKey> rowResult=findItemInRow(inputKeyString,columnSlice);
    if (rowResult.isPresent()) {
      return rowResult;
    }
  }
  return Optional.absent();
}

Fixed version (ground truth):
private Optional<DataHubKey> findFirstDifferentResult(DataHubKey inputKey,QueryResult<OrderedRows<String,String,DataHubCompositeValue>> queryResult,final boolean reversed){
  OrderedRows<String,String,DataHubCompositeValue> rows=queryResult.get();
  Iterable<Row<String,String,DataHubCompositeValue>> nonPointerRows=excludeChannelPointerItemRow(rows.getList());
  List<Row<String,String,DataHubCompositeValue>> sortedRows=getSortedRows(reversed,nonPointerRows);
  String inputKeyString=keyRenderer.keyToString(inputKey);
  for (  Row<String,String,DataHubCompositeValue> row : sortedRows) {
    ColumnSlice<String,DataHubCompositeValue> columnSlice=row.getColumnSlice();
    Optional<DataHubKey> rowResult=findItemInRow(inputKeyString,columnSlice);
    if (rowResult.isPresent()) {
      return rowResult;
    }
  }
  return Optional.absent();
}
Program: 62031
Project: 62031
Buggy source:
@Override public boolean apply(Row<String,String,DataHubCompositeValue> input){
  return !CHANNELS_LATEST_ROW_KEY.equals(input.getKey());
}

Fixed version (ground truth):
@Override public boolean apply(Row<String,String,DataHubCompositeValue> input){
  return !Arrays.asList(CHANNELS_LATEST_ROW_KEY,CHANNELS_FIRST_ROW_KEY).contains(input.getKey());
}
Program: 62032
Project: 62032
Buggy source:
private Optional<DataHubKey> findFirstDifferentResult(DataHubKey inputKey,QueryResult<OrderedRows<String,String,DataHubCompositeValue>> queryResult,final boolean reversed){
  OrderedRows<String,String,DataHubCompositeValue> rows=queryResult.get();
  Iterable<Row<String,String,DataHubCompositeValue>> nonLatestRows=excludeLatestChannelItemRow(rows.getList());
  List<Row<String,String,DataHubCompositeValue>> sortedRows=getSortedRows(reversed,nonLatestRows);
  String inputKeyString=keyRenderer.keyToString(inputKey);
  for (  Row<String,String,DataHubCompositeValue> row : sortedRows) {
    ColumnSlice<String,DataHubCompositeValue> columnSlice=row.getColumnSlice();
    Optional<DataHubKey> rowResult=findItemInRow(inputKeyString,columnSlice);
    if (rowResult.isPresent()) {
      return rowResult;
    }
  }
  return Optional.absent();
}

Fixed version (ground truth):
private Optional<DataHubKey> findFirstDifferentResult(DataHubKey inputKey,QueryResult<OrderedRows<String,String,DataHubCompositeValue>> queryResult,final boolean reversed){
  OrderedRows<String,String,DataHubCompositeValue> rows=queryResult.get();
  Iterable<Row<String,String,DataHubCompositeValue>> nonPointerRows=excludeChannelPointerItemRow(rows.getList());
  List<Row<String,String,DataHubCompositeValue>> sortedRows=getSortedRows(reversed,nonPointerRows);
  String inputKeyString=keyRenderer.keyToString(inputKey);
  for (  Row<String,String,DataHubCompositeValue> row : sortedRows) {
    ColumnSlice<String,DataHubCompositeValue> columnSlice=row.getColumnSlice();
    Optional<DataHubKey> rowResult=findItemInRow(inputKeyString,columnSlice);
    if (rowResult.isPresent()) {
      return rowResult;
    }
  }
  return Optional.absent();
}
Program: 62033
Project: 62033
Buggy source:
@Override public boolean apply(Row<String,String,DataHubCompositeValue> input){
  return !CHANNELS_LATEST_ROW_KEY.equals(input.getKey());
}

Fixed version (ground truth):
@Override public boolean apply(Row<String,String,DataHubCompositeValue> input){
  return !Arrays.asList(CHANNELS_LATEST_ROW_KEY,CHANNELS_FIRST_ROW_KEY).contains(input.getKey());
}
Program: 62034
Project: 62034
Buggy source:
private DataHubKey createKeyWithCollision(Date keyDate,AtomicNumber sequenceNumber){
  return new DataHubKey(keyDate,(short)sequenceNumber.getAndAdd(1));
}

Fixed version (ground truth):
private DataHubKey createKeyWithCollision(Date keyDate,AtomicNumber sequenceNumber){
  return new DataHubKey(keyDate,(short)sequenceNumber.addAndGet(1));
}
Program: 62035
Project: 62035
Buggy source:
private DataHubKey createKeyWithCollision(Date keyDate,AtomicNumber sequenceNumber){
  return new DataHubKey(keyDate,(short)sequenceNumber.getAndAdd(1));
}

Fixed version (ground truth):
private DataHubKey createKeyWithCollision(Date keyDate,AtomicNumber sequenceNumber){
  return new DataHubKey(keyDate,(short)sequenceNumber.addAndGet(1));
}
Program: 62036
Project: 62036
Buggy source:
private DataHubKey createKeyWithCollision(Date keyDate,AtomicNumber sequenceNumber){
  return new DataHubKey(keyDate,(short)sequenceNumber.getAndAdd(1));
}

Fixed version (ground truth):
private DataHubKey createKeyWithCollision(Date keyDate,AtomicNumber sequenceNumber){
  return new DataHubKey(keyDate,(short)sequenceNumber.addAndGet(1));
}
Program: 62037
Project: 62037
Buggy source:
private DataHubKey createKeyWithCollision(Date keyDate,AtomicNumber sequenceNumber){
  return new DataHubKey(keyDate,(short)sequenceNumber.getAndAdd(1));
}

Fixed version (ground truth):
private DataHubKey createKeyWithCollision(Date keyDate,AtomicNumber sequenceNumber){
  return new DataHubKey(keyDate,(short)sequenceNumber.addAndGet(1));
}
Program: 62038
Project: 62038
Buggy source:
@POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public Linked<ChannelConfiguration> createChannel(ChannelCreationRequest channelCreationRequest){
  String channelName=channelCreationRequest.getName();
  ChannelConfiguration channelConfiguration=channelDao.createChannel(channelName);
  return linked(channelConfiguration).withLink("String_Node_Str",linkBuilder.buildChannelUri(channelConfiguration)).withLink("String_Node_Str",linkBuilder.buildLatestUri(channelName)).withLink("String_Node_Str",linkBuilder.buildWsLinkFor(channelName)).build();
}

Fixed version (ground truth):
@POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public Response createChannel(ChannelCreationRequest channelCreationRequest){
  String channelName=channelCreationRequest.getName();
  if (channelName == null || Strings.isNullOrEmpty(channelName.trim())) {
    return Response.status(Response.Status.BAD_REQUEST).entity("String_Node_Str").build();
  }
  ChannelConfiguration channelConfiguration=channelDao.createChannel(channelName);
  URI channelUri=linkBuilder.buildChannelUri(channelConfiguration);
  return Response.ok(linked(channelConfiguration).withLink("String_Node_Str",channelUri).withLink("String_Node_Str",linkBuilder.buildLatestUri(channelName)).withLink("String_Node_Str",linkBuilder.buildWsLinkFor(channelName)).build()).build();
}
Program: 62039
Project: 62039
Buggy source:
@Test public void testChannelCreation() throws Exception {
  String channelName="String_Node_Str";
  ChannelCreationRequest channelCreationRequest=new ChannelCreationRequest(channelName);
  Date date=new Date();
  ChannelConfiguration channelConfiguration=new ChannelConfiguration(channelName,date);
  String channelUri="String_Node_Str";
  String latestUri="String_Node_Str";
  String wsUri="String_Node_Str";
  Linked<ChannelConfiguration> expected=Linked.linked(channelConfiguration).withLink("String_Node_Str",channelUri).withLink("String_Node_Str",latestUri).withLink("String_Node_Str",wsUri).build();
  UriInfo uriInfo=mock(UriInfo.class);
  ChannelDao dao=mock(ChannelDao.class);
  ChannelHypermediaLinkBuilder linkBuilder=mock(ChannelHypermediaLinkBuilder.class);
  when(uriInfo.getRequestUri()).thenReturn(URI.create("String_Node_Str"));
  when(dao.channelExists(channelName)).thenReturn(false);
  when(dao.createChannel(channelName)).thenReturn(channelConfiguration);
  when(linkBuilder.buildChannelUri(channelConfiguration)).thenReturn(URI.create(channelUri));
  when(linkBuilder.buildLatestUri(channelName)).thenReturn(URI.create(latestUri));
  when(linkBuilder.buildWsLinkFor(channelName)).thenReturn(URI.create(wsUri));
  ChannelResource testClass=new ChannelResource(dao,linkBuilder);
  Linked<ChannelConfiguration> result=testClass.createChannel(channelCreationRequest);
  verify(dao).createChannel(channelName);
  assertEquals(expected,result);
}

Fixed version (ground truth):
@Test public void testChannelCreation() throws Exception {
  String channelName="String_Node_Str";
  ChannelCreationRequest channelCreationRequest=new ChannelCreationRequest(channelName);
  Date date=new Date();
  ChannelConfiguration channelConfiguration=new ChannelConfiguration(channelName,date);
  String channelUri="String_Node_Str";
  String latestUri="String_Node_Str";
  String wsUri="String_Node_Str";
  Linked<ChannelConfiguration> expected=Linked.linked(channelConfiguration).withLink("String_Node_Str",channelUri).withLink("String_Node_Str",latestUri).withLink("String_Node_Str",wsUri).build();
  UriInfo uriInfo=mock(UriInfo.class);
  ChannelDao dao=mock(ChannelDao.class);
  ChannelHypermediaLinkBuilder linkBuilder=mock(ChannelHypermediaLinkBuilder.class);
  when(uriInfo.getRequestUri()).thenReturn(URI.create("String_Node_Str"));
  when(dao.channelExists(channelName)).thenReturn(false);
  when(dao.createChannel(channelName)).thenReturn(channelConfiguration);
  when(linkBuilder.buildChannelUri(channelConfiguration)).thenReturn(URI.create(channelUri));
  when(linkBuilder.buildLatestUri(channelName)).thenReturn(URI.create(latestUri));
  when(linkBuilder.buildWsLinkFor(channelName)).thenReturn(URI.create(wsUri));
  ChannelResource testClass=new ChannelResource(dao,linkBuilder);
  Response response=testClass.createChannel(channelCreationRequest);
  verify(dao).createChannel(channelName);
  assertEquals(200,response.getStatus());
  assertEquals(expected,response.getEntity());
}
Program: 62040
Project: 62040
Buggy source:
@POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public Linked<ChannelConfiguration> createChannel(ChannelCreationRequest channelCreationRequest){
  String channelName=channelCreationRequest.getName();
  ChannelConfiguration channelConfiguration=channelDao.createChannel(channelName);
  return linked(channelConfiguration).withLink("String_Node_Str",linkBuilder.buildChannelUri(channelConfiguration)).withLink("String_Node_Str",linkBuilder.buildLatestUri(channelName)).withLink("String_Node_Str",linkBuilder.buildWsLinkFor(channelName)).build();
}

Fixed version (ground truth):
@POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public Response createChannel(ChannelCreationRequest channelCreationRequest){
  String channelName=channelCreationRequest.getName();
  if (channelName == null || Strings.isNullOrEmpty(channelName.trim())) {
    return Response.status(Response.Status.BAD_REQUEST).entity("String_Node_Str").build();
  }
  ChannelConfiguration channelConfiguration=channelDao.createChannel(channelName);
  URI channelUri=linkBuilder.buildChannelUri(channelConfiguration);
  return Response.ok(linked(channelConfiguration).withLink("String_Node_Str",channelUri).withLink("String_Node_Str",linkBuilder.buildLatestUri(channelName)).withLink("String_Node_Str",linkBuilder.buildWsLinkFor(channelName)).build()).build();
}
Program: 62041
Project: 62041
Buggy source:
@Test public void testChannelCreation() throws Exception {
  String channelName="String_Node_Str";
  ChannelCreationRequest channelCreationRequest=new ChannelCreationRequest(channelName);
  Date date=new Date();
  ChannelConfiguration channelConfiguration=new ChannelConfiguration(channelName,date);
  String channelUri="String_Node_Str";
  String latestUri="String_Node_Str";
  String wsUri="String_Node_Str";
  Linked<ChannelConfiguration> expected=Linked.linked(channelConfiguration).withLink("String_Node_Str",channelUri).withLink("String_Node_Str",latestUri).withLink("String_Node_Str",wsUri).build();
  UriInfo uriInfo=mock(UriInfo.class);
  ChannelDao dao=mock(ChannelDao.class);
  ChannelHypermediaLinkBuilder linkBuilder=mock(ChannelHypermediaLinkBuilder.class);
  when(uriInfo.getRequestUri()).thenReturn(URI.create("String_Node_Str"));
  when(dao.channelExists(channelName)).thenReturn(false);
  when(dao.createChannel(channelName)).thenReturn(channelConfiguration);
  when(linkBuilder.buildChannelUri(channelConfiguration)).thenReturn(URI.create(channelUri));
  when(linkBuilder.buildLatestUri(channelName)).thenReturn(URI.create(latestUri));
  when(linkBuilder.buildWsLinkFor(channelName)).thenReturn(URI.create(wsUri));
  ChannelResource testClass=new ChannelResource(dao,linkBuilder);
  Linked<ChannelConfiguration> result=testClass.createChannel(channelCreationRequest);
  verify(dao).createChannel(channelName);
  assertEquals(expected,result);
}

Fixed version (ground truth):
@Test public void testChannelCreation() throws Exception {
  String channelName="String_Node_Str";
  ChannelCreationRequest channelCreationRequest=new ChannelCreationRequest(channelName);
  Date date=new Date();
  ChannelConfiguration channelConfiguration=new ChannelConfiguration(channelName,date);
  String channelUri="String_Node_Str";
  String latestUri="String_Node_Str";
  String wsUri="String_Node_Str";
  Linked<ChannelConfiguration> expected=Linked.linked(channelConfiguration).withLink("String_Node_Str",channelUri).withLink("String_Node_Str",latestUri).withLink("String_Node_Str",wsUri).build();
  UriInfo uriInfo=mock(UriInfo.class);
  ChannelDao dao=mock(ChannelDao.class);
  ChannelHypermediaLinkBuilder linkBuilder=mock(ChannelHypermediaLinkBuilder.class);
  when(uriInfo.getRequestUri()).thenReturn(URI.create("String_Node_Str"));
  when(dao.channelExists(channelName)).thenReturn(false);
  when(dao.createChannel(channelName)).thenReturn(channelConfiguration);
  when(linkBuilder.buildChannelUri(channelConfiguration)).thenReturn(URI.create(channelUri));
  when(linkBuilder.buildLatestUri(channelName)).thenReturn(URI.create(latestUri));
  when(linkBuilder.buildWsLinkFor(channelName)).thenReturn(URI.create(wsUri));
  ChannelResource testClass=new ChannelResource(dao,linkBuilder);
  Response response=testClass.createChannel(channelCreationRequest);
  verify(dao).createChannel(channelName);
  assertEquals(200,response.getStatus());
  assertEquals(expected,response.getEntity());
}
Program: 62042
Project: 62042
Buggy source:
private Optional<DataHubKey> findFirstDifferentResult(DataHubKey inputKey,QueryResult<OrderedRows<String,String,DataHubCompositeValue>> queryResult,final boolean reversed){
  OrderedRows<String,String,DataHubCompositeValue> rows=queryResult.get();
  List<Row<String,String,DataHubCompositeValue>> sortedRows=getSortedRows(reversed,rows.getList());
  String inputKeyString=keyRenderer.keyToString(inputKey);
  for (  Row<String,String,DataHubCompositeValue> row : sortedRows) {
    ColumnSlice<String,DataHubCompositeValue> columnSlice=row.getColumnSlice();
    Optional<DataHubKey> rowResult=findItemInRow(inputKeyString,columnSlice);
    if (rowResult.isPresent()) {
      return rowResult;
    }
  }
  return Optional.absent();
}

Fixed version (ground truth):
private Optional<DataHubKey> findFirstDifferentResult(DataHubKey inputKey,QueryResult<OrderedRows<String,String,DataHubCompositeValue>> queryResult,final boolean reversed){
  OrderedRows<String,String,DataHubCompositeValue> rows=queryResult.get();
  Iterable<Row<String,String,DataHubCompositeValue>> nonLatestRows=excludeLatestChannelItemRow(rows.getList());
  List<Row<String,String,DataHubCompositeValue>> sortedRows=getSortedRows(reversed,nonLatestRows);
  String inputKeyString=keyRenderer.keyToString(inputKey);
  for (  Row<String,String,DataHubCompositeValue> row : sortedRows) {
    ColumnSlice<String,DataHubCompositeValue> columnSlice=row.getColumnSlice();
    Optional<DataHubKey> rowResult=findItemInRow(inputKeyString,columnSlice);
    if (rowResult.isPresent()) {
      return rowResult;
    }
  }
  return Optional.absent();
}
Program: 62043
Project: 62043
Buggy source:
private List<Row<String,String,DataHubCompositeValue>> getSortedRows(final boolean reversed,List<Row<String,String,DataHubCompositeValue>> rowsList){
  return Ordering.from(new Comparator<Row<String,String,DataHubCompositeValue>>(){
    @Override public int compare(    Row<String,String,DataHubCompositeValue> o1,    Row<String,String,DataHubCompositeValue> o2){
      String key1=o1.getKey();
      String key2=o2.getKey();
      return reversed ? key2.compareTo(key1) : key1.compareTo(key2);
    }
  }
).sortedCopy(rowsList);
}

Fixed version (ground truth):
private List<Row<String,String,DataHubCompositeValue>> getSortedRows(final boolean reversed,Iterable<Row<String,String,DataHubCompositeValue>> rowsList){
  return Ordering.from(new Comparator<Row<String,String,DataHubCompositeValue>>(){
    @Override public int compare(    Row<String,String,DataHubCompositeValue> o1,    Row<String,String,DataHubCompositeValue> o2){
      String key1=o1.getKey();
      String key2=o2.getKey();
      return reversed ? key2.compareTo(key1) : key1.compareTo(key2);
    }
  }
).sortedCopy(rowsList);
}
Program: 62044
Project: 62044
Buggy source:
@Before public void setup(){
  channelName="String_Node_Str";
  keyRenderer=new DataHubKeyRenderer();
  targetKey=new DataHubKey(new Date(555L),(short)1);
  expectedPrevious=new DataHubKey(new Date(554L),(short)0);
  expectedNext=new DataHubKey(new Date(556L),(short)0);
  connector=mock(CassandraConnector.class);
  hector=mock(HectorFactoryWrapper.class);
  keyspace=mock(Keyspace.class);
  rangeQuery=mock(RangeSlicesQuery.class);
  queryResult=mock(QueryResult.class);
  orderedRows=mock(OrderedRows.class);
  column=mock(HColumn.class);
  previousColumn=mock(HColumn.class);
  nextColumn=mock(HColumn.class);
  row=mock(Row.class);
  row1=mock(Row.class);
  row2=mock(Row.class);
  columnSlice=mock(ColumnSlice.class);
  columnSlice1=mock(ColumnSlice.class);
  columnSlice2=mock(ColumnSlice.class);
  when(connector.getKeyspace()).thenReturn(keyspace);
  when(hector.createRangeSlicesQuery(keyspace,StringSerializer.get(),StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(rangeQuery);
  when(rangeQuery.setColumnFamily(channelName)).thenReturn(rangeQuery);
  when(rangeQuery.execute()).thenReturn(queryResult);
  when(row1.getKey()).thenReturn("String_Node_Str");
  when(row2.getKey()).thenReturn("String_Node_Str");
  when(row.getColumnSlice()).thenReturn(columnSlice);
  when(row1.getColumnSlice()).thenReturn(columnSlice1);
  when(row2.getColumnSlice()).thenReturn(columnSlice2);
}

Fixed version (ground truth):
@Before public void setup(){
  channelName="String_Node_Str";
  keyRenderer=new DataHubKeyRenderer();
  targetKey=new DataHubKey(new Date(555L),(short)1);
  expectedPrevious=new DataHubKey(new Date(554L),(short)0);
  expectedNext=new DataHubKey(new Date(556L),(short)0);
  connector=mock(CassandraConnector.class);
  hector=mock(HectorFactoryWrapper.class);
  keyspace=mock(Keyspace.class);
  rangeQuery=mock(RangeSlicesQuery.class);
  queryResult=mock(QueryResult.class);
  orderedRows=mock(OrderedRows.class);
  column=mock(HColumn.class);
  previousColumn=mock(HColumn.class);
  nextColumn=mock(HColumn.class);
  row=mock(Row.class);
  latestItemRow=mock(Row.class);
  row1=mock(Row.class);
  row2=mock(Row.class);
  columnSlice=mock(ColumnSlice.class);
  columnSlice1=mock(ColumnSlice.class);
  columnSlice2=mock(ColumnSlice.class);
  when(connector.getKeyspace()).thenReturn(keyspace);
  when(hector.createRangeSlicesQuery(keyspace,StringSerializer.get(),StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(rangeQuery);
  when(rangeQuery.setColumnFamily(channelName)).thenReturn(rangeQuery);
  when(rangeQuery.execute()).thenReturn(queryResult);
  when(row1.getKey()).thenReturn("String_Node_Str");
  when(row2.getKey()).thenReturn("String_Node_Str");
  when(row.getColumnSlice()).thenReturn(columnSlice);
  when(latestItemRow.getKey()).thenReturn(CHANNELS_LATEST_ROW_KEY);
  when(row1.getColumnSlice()).thenReturn(columnSlice1);
  when(row2.getColumnSlice()).thenReturn(columnSlice2);
}
Program: 62045
Project: 62045
Buggy source:
private Optional<DataHubKey> findFirstDifferentResult(DataHubKey inputKey,QueryResult<OrderedRows<String,String,DataHubCompositeValue>> queryResult,final boolean reversed){
  OrderedRows<String,String,DataHubCompositeValue> rows=queryResult.get();
  List<Row<String,String,DataHubCompositeValue>> sortedRows=getSortedRows(reversed,rows.getList());
  String inputKeyString=keyRenderer.keyToString(inputKey);
  for (  Row<String,String,DataHubCompositeValue> row : sortedRows) {
    ColumnSlice<String,DataHubCompositeValue> columnSlice=row.getColumnSlice();
    Optional<DataHubKey> rowResult=findItemInRow(inputKeyString,columnSlice);
    if (rowResult.isPresent()) {
      return rowResult;
    }
  }
  return Optional.absent();
}

Fixed version (ground truth):
private Optional<DataHubKey> findFirstDifferentResult(DataHubKey inputKey,QueryResult<OrderedRows<String,String,DataHubCompositeValue>> queryResult,final boolean reversed){
  OrderedRows<String,String,DataHubCompositeValue> rows=queryResult.get();
  Iterable<Row<String,String,DataHubCompositeValue>> nonLatestRows=excludeLatestChannelItemRow(rows.getList());
  List<Row<String,String,DataHubCompositeValue>> sortedRows=getSortedRows(reversed,nonLatestRows);
  String inputKeyString=keyRenderer.keyToString(inputKey);
  for (  Row<String,String,DataHubCompositeValue> row : sortedRows) {
    ColumnSlice<String,DataHubCompositeValue> columnSlice=row.getColumnSlice();
    Optional<DataHubKey> rowResult=findItemInRow(inputKeyString,columnSlice);
    if (rowResult.isPresent()) {
      return rowResult;
    }
  }
  return Optional.absent();
}
Program: 62046
Project: 62046
Buggy source:
private List<Row<String,String,DataHubCompositeValue>> getSortedRows(final boolean reversed,List<Row<String,String,DataHubCompositeValue>> rowsList){
  return Ordering.from(new Comparator<Row<String,String,DataHubCompositeValue>>(){
    @Override public int compare(    Row<String,String,DataHubCompositeValue> o1,    Row<String,String,DataHubCompositeValue> o2){
      String key1=o1.getKey();
      String key2=o2.getKey();
      return reversed ? key2.compareTo(key1) : key1.compareTo(key2);
    }
  }
).sortedCopy(rowsList);
}

Fixed version (ground truth):
private List<Row<String,String,DataHubCompositeValue>> getSortedRows(final boolean reversed,Iterable<Row<String,String,DataHubCompositeValue>> rowsList){
  return Ordering.from(new Comparator<Row<String,String,DataHubCompositeValue>>(){
    @Override public int compare(    Row<String,String,DataHubCompositeValue> o1,    Row<String,String,DataHubCompositeValue> o2){
      String key1=o1.getKey();
      String key2=o2.getKey();
      return reversed ? key2.compareTo(key1) : key1.compareTo(key2);
    }
  }
).sortedCopy(rowsList);
}
Program: 62047
Project: 62047
Buggy source:
@Before public void setup(){
  channelName="String_Node_Str";
  keyRenderer=new DataHubKeyRenderer();
  targetKey=new DataHubKey(new Date(555L),(short)1);
  expectedPrevious=new DataHubKey(new Date(554L),(short)0);
  expectedNext=new DataHubKey(new Date(556L),(short)0);
  connector=mock(CassandraConnector.class);
  hector=mock(HectorFactoryWrapper.class);
  keyspace=mock(Keyspace.class);
  rangeQuery=mock(RangeSlicesQuery.class);
  queryResult=mock(QueryResult.class);
  orderedRows=mock(OrderedRows.class);
  column=mock(HColumn.class);
  previousColumn=mock(HColumn.class);
  nextColumn=mock(HColumn.class);
  row=mock(Row.class);
  row1=mock(Row.class);
  row2=mock(Row.class);
  columnSlice=mock(ColumnSlice.class);
  columnSlice1=mock(ColumnSlice.class);
  columnSlice2=mock(ColumnSlice.class);
  when(connector.getKeyspace()).thenReturn(keyspace);
  when(hector.createRangeSlicesQuery(keyspace,StringSerializer.get(),StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(rangeQuery);
  when(rangeQuery.setColumnFamily(channelName)).thenReturn(rangeQuery);
  when(rangeQuery.execute()).thenReturn(queryResult);
  when(row1.getKey()).thenReturn("String_Node_Str");
  when(row2.getKey()).thenReturn("String_Node_Str");
  when(row.getColumnSlice()).thenReturn(columnSlice);
  when(row1.getColumnSlice()).thenReturn(columnSlice1);
  when(row2.getColumnSlice()).thenReturn(columnSlice2);
}

Fixed version (ground truth):
@Before public void setup(){
  channelName="String_Node_Str";
  keyRenderer=new DataHubKeyRenderer();
  targetKey=new DataHubKey(new Date(555L),(short)1);
  expectedPrevious=new DataHubKey(new Date(554L),(short)0);
  expectedNext=new DataHubKey(new Date(556L),(short)0);
  connector=mock(CassandraConnector.class);
  hector=mock(HectorFactoryWrapper.class);
  keyspace=mock(Keyspace.class);
  rangeQuery=mock(RangeSlicesQuery.class);
  queryResult=mock(QueryResult.class);
  orderedRows=mock(OrderedRows.class);
  column=mock(HColumn.class);
  previousColumn=mock(HColumn.class);
  nextColumn=mock(HColumn.class);
  row=mock(Row.class);
  latestItemRow=mock(Row.class);
  row1=mock(Row.class);
  row2=mock(Row.class);
  columnSlice=mock(ColumnSlice.class);
  columnSlice1=mock(ColumnSlice.class);
  columnSlice2=mock(ColumnSlice.class);
  when(connector.getKeyspace()).thenReturn(keyspace);
  when(hector.createRangeSlicesQuery(keyspace,StringSerializer.get(),StringSerializer.get(),DataHubCompositeValueSerializer.get())).thenReturn(rangeQuery);
  when(rangeQuery.setColumnFamily(channelName)).thenReturn(rangeQuery);
  when(rangeQuery.execute()).thenReturn(queryResult);
  when(row1.getKey()).thenReturn("String_Node_Str");
  when(row2.getKey()).thenReturn("String_Node_Str");
  when(row.getColumnSlice()).thenReturn(columnSlice);
  when(latestItemRow.getKey()).thenReturn(CHANNELS_LATEST_ROW_KEY);
  when(row1.getColumnSlice()).thenReturn(columnSlice1);
  when(row2.getColumnSlice()).thenReturn(columnSlice2);
}
Program: 62048
Project: 62048
Buggy source:
@Override public Optional<LinkedDataHubCompositeValue> getValue(String channelName,DataHubKey key){
  return Optional.fromNullable(channelValues.getIfPresent(key));
}

Fixed version (ground truth):
@Override public Optional<LinkedDataHubCompositeValue> getValue(String channelName,DataHubKey key){
  return Optional.fromNullable(channelValues.getIfPresent(new DataHubChannelValueKey(key,channelName)));
}
Program: 62049
Project: 62049
Buggy source:
@Override public Optional<DataHubKey> findLatestId(String channelName){
  DataHubKey key=latestPerChannel.get(channelName);
  return Optional.fromNullable(key);
}

Fixed version (ground truth):
@Override public Optional<DataHubKey> findLatestId(String channelName){
  DataHubChannelValueKey key=latestPerChannel.get(channelName);
  return optionalFromCompositeKey(key);
}
Program: 62050
Project: 62050
Buggy source:
@Override public ValueInsertionResult insert(String channelName,String contentType,byte[] data){
  Lock lock=writeLocks.get(channelName);
  lock.lock();
  try {
    DataHubKey oldLastKey=latestPerChannel.get(channelName);
    short newSequence=(oldLastKey == null) ? ((short)0) : (short)(oldLastKey.getSequence() + 1);
    DataHubKey newKey=new DataHubKey(timeProvider.getDate(),newSequence);
    DataHubCompositeValue dataHubCompositeValue=new DataHubCompositeValue(contentType,data);
    LinkedDataHubCompositeValue newLinkedValue=new LinkedDataHubCompositeValue(dataHubCompositeValue,Optional.fromNullable(oldLastKey),Optional.<DataHubKey>absent());
    channelValues.put(newKey,newLinkedValue);
    linkOldPreviousToNew(oldLastKey,newKey);
    latestPerChannel.put(channelName,newKey);
    return new ValueInsertionResult(newKey);
  }
  finally {
    lock.unlock();
  }
}

Fixed version (ground truth):
@Override public ValueInsertionResult insert(String channelName,String contentType,byte[] data){
  Lock lock=writeLocks.get(channelName);
  lock.lock();
  try {
    DataHubChannelValueKey oldLastKey=latestPerChannel.get(channelName);
    short newSequence=(oldLastKey == null) ? ((short)0) : (short)(oldLastKey.sequence + 1);
    DataHubKey newKey=new DataHubKey(timeProvider.getDate(),newSequence);
    DataHubChannelValueKey newDataHubChannelValueKey=new DataHubChannelValueKey(newKey,channelName);
    DataHubCompositeValue dataHubCompositeValue=new DataHubCompositeValue(contentType,data);
    LinkedDataHubCompositeValue newLinkedValue=new LinkedDataHubCompositeValue(dataHubCompositeValue,optionalFromCompositeKey(oldLastKey),Optional.<DataHubKey>absent());
    channelValues.put(newDataHubChannelValueKey,newLinkedValue);
    linkOldPreviousToNew(oldLastKey,newDataHubChannelValueKey);
    latestPerChannel.put(channelName,newDataHubChannelValueKey);
    return new ValueInsertionResult(newKey);
  }
  finally {
    lock.unlock();
  }
}
Program: 62051
Project: 62051
Buggy source:
private void linkOldPreviousToNew(DataHubKey oldLastKey,DataHubKey newKey){
  if (oldLastKey != null) {
    LinkedDataHubCompositeValue previousLinkedValue=channelValues.getIfPresent(oldLastKey);
    if (previousLinkedValue != null) {
      channelValues.put(oldLastKey,new LinkedDataHubCompositeValue(previousLinkedValue.getValue(),previousLinkedValue.getPrevious(),Optional.of(newKey)));
    }
  }
}

Fixed version (ground truth):
private void linkOldPreviousToNew(DataHubChannelValueKey oldLastKey,DataHubChannelValueKey newKey){
  if (oldLastKey != null) {
    LinkedDataHubCompositeValue previousLinkedValue=channelValues.getIfPresent(oldLastKey);
    if (previousLinkedValue != null) {
      channelValues.put(oldLastKey,new LinkedDataHubCompositeValue(previousLinkedValue.getValue(),previousLinkedValue.getPrevious(),Optional.of(new DataHubKey(newKey.date,newKey.sequence))));
    }
  }
}
Program: 62052
Project: 62052
Buggy source:
@Test public void testFindLatestId() throws Exception {
  InMemoryChannelDao testClass=new InMemoryChannelDao(mock(TimeProvider.class));
  testClass.createChannel("String_Node_Str");
  assertFalse(testClass.findLatestId("String_Node_Str").isPresent());
  ValueInsertionResult insertionResult=testClass.insert("String_Node_Str","String_Node_Str","String_Node_Str".getBytes());
  assertEquals(insertionResult.getKey(),testClass.findLatestId("String_Node_Str").get());
}

Fixed version (ground truth):
@Test public void testFindLatestId() throws Exception {
  InMemoryChannelDao testClass=new InMemoryChannelDao(new TimeProvider());
  testClass.createChannel("String_Node_Str");
  assertFalse(testClass.findLatestId("String_Node_Str").isPresent());
  ValueInsertionResult insertionResult=testClass.insert("String_Node_Str","String_Node_Str","String_Node_Str".getBytes());
  assertEquals(insertionResult.getKey(),testClass.findLatestId("String_Node_Str").get());
}
Program: 62053
Project: 62053
Buggy source:
private void insertChannelMetadata(ChannelConfiguration channelConfig){
  StringSerializer keySerializer=StringSerializer.get();
  Mutator<String> mutator=connector.buildMutator(keySerializer);
  HColumn<String,ChannelConfiguration> column=hector.createColumn(channelConfig.getName(),channelConfig,StringSerializer.get(),channelConfigSerializer);
  mutator.insert(CHANNELS_ROW_KEY,CHANNELS_COLUMN_FAMILY_NAME,column);
}

Fixed version (ground truth):
private void insertChannelMetadata(ChannelConfiguration channelConfig){
  connector.createColumnFamily(CHANNELS_COLUMN_FAMILY_NAME);
  StringSerializer keySerializer=StringSerializer.get();
  Mutator<String> mutator=connector.buildMutator(keySerializer);
  HColumn<String,ChannelConfiguration> column=hector.createColumn(channelConfig.getName(),channelConfig,StringSerializer.get(),channelConfigSerializer);
  mutator.insert(CHANNELS_ROW_KEY,CHANNELS_COLUMN_FAMILY_NAME,column);
}
Program: 62054
Project: 62054
Buggy source:
public DataHubCompositeValue read(String channelName,DataHubKey key){
  Keyspace keyspace=connector.getKeyspace();
  ColumnQuery<String,String,DataHubCompositeValue> query=hector.createColumnQuery(keyspace,StringSerializer.get(),StringSerializer.get(),DataHubCompositeValueSerializer.get());
  String rowKey=rowKeyStrategy.buildKey(channelName,key);
  QueryResult<HColumn<String,DataHubCompositeValue>> queryResult=query.setColumnFamily(channelName).setKey(rowKey).setName(keyRenderer.keyToString(key)).execute();
  HColumn<String,DataHubCompositeValue> column=queryResult.get();
  return column == null ? null : column.getValue();
}

Fixed version (ground truth):
public DataHubCompositeValue read(String channelName,DataHubKey key){
  Keyspace keyspace=connector.getKeyspace();
  ColumnQuery<String,String,DataHubCompositeValue> query=hector.createColumnQuery(keyspace,StringSerializer.get(),StringSerializer.get(),DataHubCompositeValueSerializer.get());
  String rowKey=rowKeyStrategy.buildKey(channelName,key);
  try {
    return executeQuery(channelName,key,query,rowKey);
  }
 catch (  HInvalidRequestException e) {
    throw maybePromoteToNoSuchChannel(e,channelName);
  }
}
Program: 62055
Project: 62055
Buggy source:
public Optional<DataHubKey> findLatestId(String channelName){
  DataHubKey lastUpdatedKey=channelsCollection.getLastUpdatedKey(channelName);
  return Optional.fromNullable(lastUpdatedKey);
}

Fixed version (ground truth):
public Optional<DataHubKey> findLatestId(String channelName){
  try {
    DataHubKey lastUpdatedKey=channelsCollection.getLastUpdatedKey(channelName);
    return Optional.fromNullable(lastUpdatedKey);
  }
 catch (  HInvalidRequestException e) {
    throw maybePromoteToNoSuchChannel(e,channelName);
  }
}
Program: 62056
Project: 62056
Buggy source:
public ValueInsertionResult write(String channelName,DataHubCompositeValue columnValue){
  Mutator<String> mutator=connector.buildMutator(StringSerializer.get());
  DataHubKey key=keyGenerator.newKey();
  String columnName=keyRenderer.keyToString(key);
  HColumn<String,DataHubCompositeValue> column=hector.createColumn(columnName,columnValue,StringSerializer.get(),DataHubCompositeValueSerializer.get());
  String rowKey=rowKeyStrategy.buildKey(channelName,key);
  try {
    mutator.insert(rowKey,channelName,column);
  }
 catch (  HInvalidRequestException e) {
    if (e.getMessage().contains("String_Node_Str")) {
      throw new NoSuchChannelException("String_Node_Str" + channelName,e);
    }
    throw e;
  }
  return new ValueInsertionResult(key);
}

Fixed version (ground truth):
public ValueInsertionResult write(String channelName,DataHubCompositeValue columnValue){
  Mutator<String> mutator=connector.buildMutator(StringSerializer.get());
  DataHubKey key=keyGenerator.newKey();
  String columnName=keyRenderer.keyToString(key);
  HColumn<String,DataHubCompositeValue> column=hector.createColumn(columnName,columnValue,StringSerializer.get(),DataHubCompositeValueSerializer.get());
  String rowKey=rowKeyStrategy.buildKey(channelName,key);
  try {
    mutator.insert(rowKey,channelName,column);
  }
 catch (  HInvalidRequestException e) {
    throw maybePromoteToNoSuchChannel(e,channelName);
  }
  return new ValueInsertionResult(key);
}
Program: 62057
Project: 62057
Buggy source:
@Test public void testCreateChannel() throws Exception {
  String channelName="String_Node_Str";
  final Date creationDate=new Date(99999);
  ChannelConfiguration expected=new ChannelConfiguration(channelName,creationDate);
  HColumn<String,ChannelConfiguration> column=new HColumnImpl<String,ChannelConfiguration>(StringSerializer.get(),mock(Serializer.class));
  when(connector.buildMutator(StringSerializer.get())).thenReturn(mutator);
  when(hector.createColumn(channelName,expected,StringSerializer.get(),valueSerializer)).thenReturn(column);
  when(timeProvider.getDate()).thenReturn(creationDate);
  CassandraChannelsCollection testClass=new CassandraChannelsCollection(connector,valueSerializer,hector,timeProvider,keyRenderer);
  ChannelConfiguration result=testClass.createChannel(channelName);
  assertEquals(expected,result);
  verify(connector).createColumnFamily(channelName);
  verify(mutator).insert(CHANNELS_ROW_KEY,CHANNELS_COLUMN_FAMILY_NAME,column);
}

Fixed version (ground truth):
@Test public void testCreateChannel() throws Exception {
  String channelName="String_Node_Str";
  final Date creationDate=new Date(99999);
  ChannelConfiguration expected=new ChannelConfiguration(channelName,creationDate);
  HColumn<String,ChannelConfiguration> column=new HColumnImpl<String,ChannelConfiguration>(StringSerializer.get(),mock(Serializer.class));
  when(connector.buildMutator(StringSerializer.get())).thenReturn(mutator);
  when(hector.createColumn(channelName,expected,StringSerializer.get(),valueSerializer)).thenReturn(column);
  when(timeProvider.getDate()).thenReturn(creationDate);
  CassandraChannelsCollection testClass=new CassandraChannelsCollection(connector,valueSerializer,hector,timeProvider,keyRenderer);
  ChannelConfiguration result=testClass.createChannel(channelName);
  assertEquals(expected,result);
  verify(connector).createColumnFamily(CHANNELS_COLUMN_FAMILY_NAME);
  verify(connector).createColumnFamily(channelName);
  verify(mutator).insert(CHANNELS_ROW_KEY,CHANNELS_COLUMN_FAMILY_NAME,column);
}
Program: 62058
Project: 62058
Buggy source:
@Test public void testFindLatestId_channelNotFound() throws Exception {
  String channelName="String_Node_Str";
  CassandraChannelsCollection channelsCollection=mock(CassandraChannelsCollection.class);
  when(channelsCollection.getChannelConfiguration(channelName)).thenReturn(null);
  CassandraValueReader testClass=new CassandraValueReader(null,null,null,channelsCollection,null);
  Optional<DataHubKey> result=testClass.findLatestId(channelName);
  assertEquals(Optional.absent(),result);
}

Fixed version (ground truth):
@Test(expected=NoSuchChannelException.class) public void testFindLatestId_channelNotFound() throws Exception {
  String channelName="String_Node_Str";
  CassandraChannelsCollection channelsCollection=mock(CassandraChannelsCollection.class);
  when(channelsCollection.getLastUpdatedKey(channelName)).thenThrow(new HInvalidRequestException("String_Node_Str"));
  CassandraValueReader testClass=new CassandraValueReader(null,null,null,channelsCollection,null);
  testClass.findLatestId(channelName);
}
Program: 62059
Project: 62059
Buggy source:
private void insertChannelMetadata(ChannelConfiguration channelConfig){
  StringSerializer keySerializer=StringSerializer.get();
  Mutator<String> mutator=connector.buildMutator(keySerializer);
  HColumn<String,ChannelConfiguration> column=hector.createColumn(channelConfig.getName(),channelConfig,StringSerializer.get(),channelConfigSerializer);
  mutator.insert(CHANNELS_ROW_KEY,CHANNELS_COLUMN_FAMILY_NAME,column);
}

Fixed version (ground truth):
private void insertChannelMetadata(ChannelConfiguration channelConfig){
  connector.createColumnFamily(CHANNELS_COLUMN_FAMILY_NAME);
  StringSerializer keySerializer=StringSerializer.get();
  Mutator<String> mutator=connector.buildMutator(keySerializer);
  HColumn<String,ChannelConfiguration> column=hector.createColumn(channelConfig.getName(),channelConfig,StringSerializer.get(),channelConfigSerializer);
  mutator.insert(CHANNELS_ROW_KEY,CHANNELS_COLUMN_FAMILY_NAME,column);
}
Program: 62060
Project: 62060
Buggy source:
public DataHubCompositeValue read(String channelName,DataHubKey key){
  Keyspace keyspace=connector.getKeyspace();
  ColumnQuery<String,String,DataHubCompositeValue> query=hector.createColumnQuery(keyspace,StringSerializer.get(),StringSerializer.get(),DataHubCompositeValueSerializer.get());
  String rowKey=rowKeyStrategy.buildKey(channelName,key);
  QueryResult<HColumn<String,DataHubCompositeValue>> queryResult=query.setColumnFamily(channelName).setKey(rowKey).setName(keyRenderer.keyToString(key)).execute();
  HColumn<String,DataHubCompositeValue> column=queryResult.get();
  return column == null ? null : column.getValue();
}

Fixed version (ground truth):
public DataHubCompositeValue read(String channelName,DataHubKey key){
  Keyspace keyspace=connector.getKeyspace();
  ColumnQuery<String,String,DataHubCompositeValue> query=hector.createColumnQuery(keyspace,StringSerializer.get(),StringSerializer.get(),DataHubCompositeValueSerializer.get());
  String rowKey=rowKeyStrategy.buildKey(channelName,key);
  try {
    return executeQuery(channelName,key,query,rowKey);
  }
 catch (  HInvalidRequestException e) {
    throw maybePromoteToNoSuchChannel(e,channelName);
  }
}
Program: 62061
Project: 62061
Buggy source:
public Optional<DataHubKey> findLatestId(String channelName){
  DataHubKey lastUpdatedKey=channelsCollection.getLastUpdatedKey(channelName);
  return Optional.fromNullable(lastUpdatedKey);
}

Fixed version (ground truth):
public Optional<DataHubKey> findLatestId(String channelName){
  try {
    DataHubKey lastUpdatedKey=channelsCollection.getLastUpdatedKey(channelName);
    return Optional.fromNullable(lastUpdatedKey);
  }
 catch (  HInvalidRequestException e) {
    throw maybePromoteToNoSuchChannel(e,channelName);
  }
}
Program: 62062
Project: 62062
Buggy source:
public ValueInsertionResult write(String channelName,DataHubCompositeValue columnValue){
  Mutator<String> mutator=connector.buildMutator(StringSerializer.get());
  DataHubKey key=keyGenerator.newKey();
  String columnName=keyRenderer.keyToString(key);
  HColumn<String,DataHubCompositeValue> column=hector.createColumn(columnName,columnValue,StringSerializer.get(),DataHubCompositeValueSerializer.get());
  String rowKey=rowKeyStrategy.buildKey(channelName,key);
  try {
    mutator.insert(rowKey,channelName,column);
  }
 catch (  HInvalidRequestException e) {
    if (e.getMessage().contains("String_Node_Str")) {
      throw new NoSuchChannelException("String_Node_Str" + channelName,e);
    }
    throw e;
  }
  return new ValueInsertionResult(key);
}

Fixed version (ground truth):
public ValueInsertionResult write(String channelName,DataHubCompositeValue columnValue){
  Mutator<String> mutator=connector.buildMutator(StringSerializer.get());
  DataHubKey key=keyGenerator.newKey();
  String columnName=keyRenderer.keyToString(key);
  HColumn<String,DataHubCompositeValue> column=hector.createColumn(columnName,columnValue,StringSerializer.get(),DataHubCompositeValueSerializer.get());
  String rowKey=rowKeyStrategy.buildKey(channelName,key);
  try {
    mutator.insert(rowKey,channelName,column);
  }
 catch (  HInvalidRequestException e) {
    throw maybePromoteToNoSuchChannel(e,channelName);
  }
  return new ValueInsertionResult(key);
}