nus-yam/ex-repair huggingface dataset:
Program: 62063
Project: 62063
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: 62064
Project: 62064
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: 62065
Project: 62065
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: 62066
Project: 62066
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: 62067
Project: 62067
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: 62068
Project: 62068
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: 62069
Project: 62069
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: 62070
Project: 62070
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: 62071
Project: 62071
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: 62072
Project: 62072
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: 62073
Project: 62073
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: 62074
Project: 62074
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: 62075
Project: 62075
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: 62076
Project: 62076
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: 62077
Project: 62077
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: 62078
Project: 62078
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: 62079
Project: 62079
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: 62080
Project: 62080
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: 62081
Project: 62081
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: 62082
Project: 62082
Buggy source:
@Override protected void configureServlets(){
  Properties properties=loadProperties();
  Names.bindProperties(binder(),properties);
  bind(CassandraChannelDao.class).asEagerSingleton();
  bind(SubscriptionDispatcher.class).in(Singleton.class);
  bind(JettyWebSocketServlet.class).in(Singleton.class);
  bind(CassandraConnectorFactory.class).in(Singleton.class);
  bind(DataHubKeyRenderer.class).in(Singleton.class);
  bind(DataHubKeyGenerator.class).in(Singleton.class);
  bind(new TypeLiteral<Serializer<ChannelConfiguration>>(){
  }
).toInstance(jacksonHectorSerializer);
  bind(new TypeLiteral<RowKeyStrategy<String,DataHubKey,DataHubCompositeValue>>(){
  }
).to(YearMonthDayRowKeyStrategy.class);
  bind(ChannelDao.class).to(CassandraChannelDao.class).in(Singleton.class);
  serveRegex("String_Node_Str").with(JettyWebSocketServlet.class);
  serve("String_Node_Str").with(GuiceContainer.class,JERSEY_PROPERTIES);
}

Fixed version (ground truth):
@Override protected void configureServlets(){
  Properties properties=loadProperties();
  Names.bindProperties(binder(),properties);
  bind(CassandraChannelDao.class).asEagerSingleton();
  bind(ChannelLockExecutor.class).in(Singleton.class);
  bind(SubscriptionDispatcher.class).in(Singleton.class);
  bind(SubscriptionRoster.class).in(Singleton.class);
  bind(JettyWebSocketServlet.class).in(Singleton.class);
  bind(CassandraConnectorFactory.class).in(Singleton.class);
  bind(DataHubKeyRenderer.class).in(Singleton.class);
  bind(DataHubKeyGenerator.class).in(Singleton.class);
  bind(new TypeLiteral<Serializer<ChannelConfiguration>>(){
  }
).toInstance(jacksonHectorSerializer);
  bind(new TypeLiteral<RowKeyStrategy<String,DataHubKey,DataHubCompositeValue>>(){
  }
).to(YearMonthDayRowKeyStrategy.class);
  bind(ChannelDao.class).to(CassandraChannelDao.class).in(Singleton.class);
  serveRegex("String_Node_Str").with(JettyWebSocketServlet.class);
  serve("String_Node_Str").with(GuiceContainer.class,JERSEY_PROPERTIES);
}
Program: 62083
Project: 62083
Buggy source:
private Optional<DataHubKey> findFirstDifferentResult(DataHubKey inputKey,QueryResult<OrderedRows<String,String,DataHubCompositeValue>> queryResult,boolean reversed){
  OrderedRows<String,String,DataHubCompositeValue> rows=queryResult.get();
  List<Row<String,String,DataHubCompositeValue>> rowsList=rows.getList();
  if (reversed) {
    rowsList=Lists.reverse(rowsList);
  }
  String inputKeyString=keyRenderer.keyToString(inputKey);
  for (  Row<String,String,DataHubCompositeValue> row : rowsList) {
    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();
  List<Row<String,String,DataHubCompositeValue>> sortedRows=getSortedRows(rows,reversed);
  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: 62084
Project: 62084
Buggy source:
@GET public Response getValue(@PathParam("String_Node_Str") String channelName,@PathParam("String_Node_Str") String id){
  DataHubKey key=keyRenderer.fromString(id);
  Optional<LinkedDataHubCompositeValue> optionalResult=channelDao.getValue(channelName,key);
  if (!optionalResult.isPresent()) {
    throw new WebApplicationException(Response.Status.NOT_FOUND);
  }
  LinkedDataHubCompositeValue columnValue=optionalResult.get();
  Response.ResponseBuilder builder=Response.status(Response.Status.OK);
  String contentType=columnValue.getContentType();
  if (!isNullOrEmpty(contentType)) {
    builder.type(contentType);
  }
  builder.entity(columnValue.getData());
  builder.header(CREATION_DATE_HEADER.getHeaderName(),dateTimeFormatter.print(new DateTime(key.getDate())));
  addPreviousLink(columnValue,builder);
  addNextLink(columnValue,builder);
  return builder.build();
}

Fixed version (ground truth):
@GET public Response getValue(@PathParam("String_Node_Str") String channelName,@PathParam("String_Node_Str") String id){
  DataHubKey key=keyRenderer.fromString(id);
  Optional<LinkedDataHubCompositeValue> optionalResult=channelDao.getValue(channelName,key);
  if (!optionalResult.isPresent()) {
    throw new WebApplicationException(Response.Status.NOT_FOUND);
  }
  LinkedDataHubCompositeValue compositeValue=optionalResult.get();
  Response.ResponseBuilder builder=Response.status(Response.Status.OK);
  String contentType=compositeValue.getContentType();
  if (!isNullOrEmpty(contentType)) {
    builder.type(contentType);
  }
  builder.entity(compositeValue.getData());
  builder.header(CREATION_DATE_HEADER.getHeaderName(),dateTimeFormatter.print(new DateTime(key.getDate())));
  addPreviousLink(compositeValue,builder);
  addNextLink(compositeValue,builder);
  return builder.build();
}
Program: 62085
Project: 62085
Buggy source:
@Inject public SingleChannelResource(ChannelDao channelDao,SubscriptionDispatcher subscriptionDispatcher,ChannelHypermediaLinkBuilder linkBuilder){
  this.channelDao=channelDao;
  this.linkBuilder=linkBuilder;
  this.subscriptionDispatcher=subscriptionDispatcher;
}

Fixed version (ground truth):
@Inject public SingleChannelResource(ChannelDao channelDao,ChannelHypermediaLinkBuilder linkBuilder,ChannelLockExecutor channelLockExecutor,SubscriptionDispatcher subscriptionDispatcher){
  this.channelDao=channelDao;
  this.linkBuilder=linkBuilder;
  this.channelLockExecutor=channelLockExecutor;
  this.subscriptionDispatcher=subscriptionDispatcher;
}
Program: 62086
Project: 62086
Buggy source:
@POST @Produces(MediaType.APPLICATION_JSON) public Response insertValue(@HeaderParam("String_Node_Str") String contentType,@PathParam("String_Node_Str") String channelName,byte[] data){
  if (!channelDao.channelExists(channelName)) {
    throw new WebApplicationException(Response.Status.NOT_FOUND);
  }
  ValueInsertionResult insertionResult=channelDao.insert(channelName,contentType,data);
  URI payloadUri=linkBuilder.buildItemUri(insertionResult.getKey());
  subscriptionDispatcher.dispatch(channelName,payloadUri);
  Linked<ValueInsertionResult> linkedResult=linked(insertionResult).withLink("String_Node_Str",linkBuilder.buildChannelUri(channelName)).withLink("String_Node_Str",payloadUri).build();
  Response.ResponseBuilder builder=Response.status(Response.Status.OK);
  builder.entity(linkedResult);
  builder.location(payloadUri);
  return builder.build();
}

Fixed version (ground truth):
@POST @Produces(MediaType.APPLICATION_JSON) public Response insertValue(@HeaderParam("String_Node_Str") final String contentType,@PathParam("String_Node_Str") final String channelName,final byte[] data) throws ExecutionException, InterruptedException {
  if (!channelDao.channelExists(channelName)) {
    throw new WebApplicationException(Response.Status.NOT_FOUND);
  }
  Callable<ValueInsertionResult> task=new WriteAndDispatch(channelName,contentType,data);
  ValueInsertionResult insertionResult=channelLockExecutor.execute(channelName,task);
  URI payloadUri=linkBuilder.buildItemUri(insertionResult.getKey());
  Linked<ValueInsertionResult> linkedResult=linked(insertionResult).withLink("String_Node_Str",linkBuilder.buildChannelUri(channelName)).withLink("String_Node_Str",payloadUri).build();
  Response.ResponseBuilder builder=Response.status(Response.Status.OK);
  builder.entity(linkedResult);
  builder.location(payloadUri);
  return builder.build();
}
Program: 62087
Project: 62087
Buggy source:
@OnWebSocketConnect public void onConnect(final Session session){
  remoteAddress=session.getRemoteAddress().toString();
  channelName=extractChannelName(session);
  URI requestUri=session.getUpgradeRequest().getRequestURI();
  logger.info("String_Node_Str" + remoteAddress + "String_Node_Str"+ requestUri);
  endpointSender=new JettyWebsocketEndpointSender(remoteAddress,session.getRemote());
  subscriptionDispatcher.subscribe(channelName,endpointSender);
}

Fixed version (ground truth):
@OnWebSocketConnect public void onConnect(final Session session){
  URI requestUri=session.getUpgradeRequest().getRequestURI();
  logger.info("String_Node_Str" + remoteAddress + "String_Node_Str"+ requestUri);
  remoteAddress=session.getRemoteAddress().toString();
  channelName=extractChannelName(session);
  endpointSender=new JettyWebsocketEndpointSender(remoteAddress,session.getRemote());
  WebSocketEventSubscription subscription=subscriptions.subscribe(channelName,endpointSender);
  new Thread(new SubscriptionDispatchWorker(subscription)).start();
}
Program: 62088
Project: 62088
Buggy source:
@OnWebSocketClose public void onDisconnect(int statusCode,String reason){
  logger.info("String_Node_Str" + remoteAddress + "String_Node_Str"+ statusCode+ "String_Node_Str"+ reason+ "String_Node_Str");
  subscriptionDispatcher.unsubscribe(channelName,endpointSender);
}

Fixed version (ground truth):
@OnWebSocketClose public void onDisconnect(int statusCode,String reason){
  logger.info("String_Node_Str" + remoteAddress + "String_Node_Str"+ statusCode+ "String_Node_Str"+ reason+ "String_Node_Str");
  Optional<WebSocketEventSubscription> optionalSubscription=subscriptions.findSubscriptionForConsumer(channelName,endpointSender);
  if (!optionalSubscription.isPresent()) {
    logger.warn("String_Node_Str" + channelName + "String_Node_Str"+ endpointSender);
    return;
  }
  WebSocketEventSubscription subscription=optionalSubscription.get();
  subscription.getQueue().add(WebsocketEvent.SHUTDOWN);
  subscriptions.unsubscribe(channelName,subscription);
}
Program: 62089
Project: 62089
Buggy source:
@Inject public DataHubWebSocket(SubscriptionDispatcher subscriptionDispatcher){
  this.subscriptionDispatcher=subscriptionDispatcher;
}

Fixed version (ground truth):
@Inject public DataHubWebSocket(SubscriptionRoster subscriptions){
  this.subscriptions=subscriptions;
}
Program: 62090
Project: 62090
Buggy source:
@Inject public JettyWebSocketServlet(SubscriptionDispatcher subscriptionDispatcher){
  this.creator=new CustomWebSocketCreator(subscriptionDispatcher);
}

Fixed version (ground truth):
@Inject public JettyWebSocketServlet(SubscriptionRoster subscriptions){
  this.creator=new CustomWebSocketCreator(subscriptions);
}
Program: 62091
Project: 62091
Buggy source:
public CustomWebSocketCreator(SubscriptionDispatcher subscriptionDispatcher){
  this.subscriptionDispatcher=subscriptionDispatcher;
}

Fixed version (ground truth):
public CustomWebSocketCreator(SubscriptionRoster subscriptions){
  this.subscriptions=subscriptions;
}
Program: 62092
Project: 62092
Buggy source:
@Override public Object createWebSocket(UpgradeRequest req,UpgradeResponse resp){
  return new DataHubWebSocket(subscriptionDispatcher);
}

Fixed version (ground truth):
@Override public Object createWebSocket(UpgradeRequest req,UpgradeResponse resp){
  return new DataHubWebSocket(subscriptions);
}
Program: 62093
Project: 62093
Buggy source:
@Override protected void configureServlets(){
  Properties properties=loadProperties();
  Names.bindProperties(binder(),properties);
  bind(CassandraChannelDao.class).asEagerSingleton();
  bind(SubscriptionDispatcher.class).in(Singleton.class);
  bind(JettyWebSocketServlet.class).in(Singleton.class);
  bind(CassandraConnectorFactory.class).in(Singleton.class);
  bind(DataHubKeyRenderer.class).in(Singleton.class);
  bind(DataHubKeyGenerator.class).in(Singleton.class);
  bind(new TypeLiteral<Serializer<ChannelConfiguration>>(){
  }
).toInstance(jacksonHectorSerializer);
  bind(new TypeLiteral<RowKeyStrategy<String,DataHubKey,DataHubCompositeValue>>(){
  }
).to(YearMonthDayRowKeyStrategy.class);
  bind(ChannelDao.class).to(CassandraChannelDao.class).in(Singleton.class);
  serveRegex("String_Node_Str").with(JettyWebSocketServlet.class);
  serve("String_Node_Str").with(GuiceContainer.class,JERSEY_PROPERTIES);
}

Fixed version (ground truth):
@Override protected void configureServlets(){
  Properties properties=loadProperties();
  Names.bindProperties(binder(),properties);
  bind(CassandraChannelDao.class).asEagerSingleton();
  bind(ChannelLockExecutor.class).in(Singleton.class);
  bind(SubscriptionDispatcher.class).in(Singleton.class);
  bind(SubscriptionRoster.class).in(Singleton.class);
  bind(JettyWebSocketServlet.class).in(Singleton.class);
  bind(CassandraConnectorFactory.class).in(Singleton.class);
  bind(DataHubKeyRenderer.class).in(Singleton.class);
  bind(DataHubKeyGenerator.class).in(Singleton.class);
  bind(new TypeLiteral<Serializer<ChannelConfiguration>>(){
  }
).toInstance(jacksonHectorSerializer);
  bind(new TypeLiteral<RowKeyStrategy<String,DataHubKey,DataHubCompositeValue>>(){
  }
).to(YearMonthDayRowKeyStrategy.class);
  bind(ChannelDao.class).to(CassandraChannelDao.class).in(Singleton.class);
  serveRegex("String_Node_Str").with(JettyWebSocketServlet.class);
  serve("String_Node_Str").with(GuiceContainer.class,JERSEY_PROPERTIES);
}
Program: 62094
Project: 62094
Buggy source:
private Optional<DataHubKey> findFirstDifferentResult(DataHubKey inputKey,QueryResult<OrderedRows<String,String,DataHubCompositeValue>> queryResult,boolean reversed){
  OrderedRows<String,String,DataHubCompositeValue> rows=queryResult.get();
  List<Row<String,String,DataHubCompositeValue>> rowsList=rows.getList();
  if (reversed) {
    rowsList=Lists.reverse(rowsList);
  }
  String inputKeyString=keyRenderer.keyToString(inputKey);
  for (  Row<String,String,DataHubCompositeValue> row : rowsList) {
    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();
  List<Row<String,String,DataHubCompositeValue>> sortedRows=getSortedRows(rows,reversed);
  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: 62095
Project: 62095
Buggy source:
@GET public Response getValue(@PathParam("String_Node_Str") String channelName,@PathParam("String_Node_Str") String id){
  DataHubKey key=keyRenderer.fromString(id);
  Optional<LinkedDataHubCompositeValue> optionalResult=channelDao.getValue(channelName,key);
  if (!optionalResult.isPresent()) {
    throw new WebApplicationException(Response.Status.NOT_FOUND);
  }
  LinkedDataHubCompositeValue columnValue=optionalResult.get();
  Response.ResponseBuilder builder=Response.status(Response.Status.OK);
  String contentType=columnValue.getContentType();
  if (!isNullOrEmpty(contentType)) {
    builder.type(contentType);
  }
  builder.entity(columnValue.getData());
  builder.header(CREATION_DATE_HEADER.getHeaderName(),dateTimeFormatter.print(new DateTime(key.getDate())));
  addPreviousLink(columnValue,builder);
  addNextLink(columnValue,builder);
  return builder.build();
}

Fixed version (ground truth):
@GET public Response getValue(@PathParam("String_Node_Str") String channelName,@PathParam("String_Node_Str") String id){
  DataHubKey key=keyRenderer.fromString(id);
  Optional<LinkedDataHubCompositeValue> optionalResult=channelDao.getValue(channelName,key);
  if (!optionalResult.isPresent()) {
    throw new WebApplicationException(Response.Status.NOT_FOUND);
  }
  LinkedDataHubCompositeValue compositeValue=optionalResult.get();
  Response.ResponseBuilder builder=Response.status(Response.Status.OK);
  String contentType=compositeValue.getContentType();
  if (!isNullOrEmpty(contentType)) {
    builder.type(contentType);
  }
  builder.entity(compositeValue.getData());
  builder.header(CREATION_DATE_HEADER.getHeaderName(),dateTimeFormatter.print(new DateTime(key.getDate())));
  addPreviousLink(compositeValue,builder);
  addNextLink(compositeValue,builder);
  return builder.build();
}
Program: 62096
Project: 62096
Buggy source:
@Inject public SingleChannelResource(ChannelDao channelDao,SubscriptionDispatcher subscriptionDispatcher,ChannelHypermediaLinkBuilder linkBuilder){
  this.channelDao=channelDao;
  this.linkBuilder=linkBuilder;
  this.subscriptionDispatcher=subscriptionDispatcher;
}

Fixed version (ground truth):
@Inject public SingleChannelResource(ChannelDao channelDao,ChannelHypermediaLinkBuilder linkBuilder,ChannelLockExecutor channelLockExecutor,SubscriptionDispatcher subscriptionDispatcher){
  this.channelDao=channelDao;
  this.linkBuilder=linkBuilder;
  this.channelLockExecutor=channelLockExecutor;
  this.subscriptionDispatcher=subscriptionDispatcher;
}
Program: 62097
Project: 62097
Buggy source:
@POST @Produces(MediaType.APPLICATION_JSON) public Response insertValue(@HeaderParam("String_Node_Str") String contentType,@PathParam("String_Node_Str") String channelName,byte[] data){
  if (!channelDao.channelExists(channelName)) {
    throw new WebApplicationException(Response.Status.NOT_FOUND);
  }
  ValueInsertionResult insertionResult=channelDao.insert(channelName,contentType,data);
  URI payloadUri=linkBuilder.buildItemUri(insertionResult.getKey());
  subscriptionDispatcher.dispatch(channelName,payloadUri);
  Linked<ValueInsertionResult> linkedResult=linked(insertionResult).withLink("String_Node_Str",linkBuilder.buildChannelUri(channelName)).withLink("String_Node_Str",payloadUri).build();
  Response.ResponseBuilder builder=Response.status(Response.Status.OK);
  builder.entity(linkedResult);
  builder.location(payloadUri);
  return builder.build();
}

Fixed version (ground truth):
@POST @Produces(MediaType.APPLICATION_JSON) public Response insertValue(@HeaderParam("String_Node_Str") final String contentType,@PathParam("String_Node_Str") final String channelName,final byte[] data) throws ExecutionException, InterruptedException {
  if (!channelDao.channelExists(channelName)) {
    throw new WebApplicationException(Response.Status.NOT_FOUND);
  }
  Callable<ValueInsertionResult> task=new WriteAndDispatch(channelName,contentType,data);
  ValueInsertionResult insertionResult=channelLockExecutor.execute(channelName,task);
  URI payloadUri=linkBuilder.buildItemUri(insertionResult.getKey());
  Linked<ValueInsertionResult> linkedResult=linked(insertionResult).withLink("String_Node_Str",linkBuilder.buildChannelUri(channelName)).withLink("String_Node_Str",payloadUri).build();
  Response.ResponseBuilder builder=Response.status(Response.Status.OK);
  builder.entity(linkedResult);
  builder.location(payloadUri);
  return builder.build();
}
Program: 62098
Project: 62098
Buggy source:
@OnWebSocketConnect public void onConnect(final Session session){
  remoteAddress=session.getRemoteAddress().toString();
  channelName=extractChannelName(session);
  URI requestUri=session.getUpgradeRequest().getRequestURI();
  logger.info("String_Node_Str" + remoteAddress + "String_Node_Str"+ requestUri);
  endpointSender=new JettyWebsocketEndpointSender(remoteAddress,session.getRemote());
  subscriptionDispatcher.subscribe(channelName,endpointSender);
}

Fixed version (ground truth):
@OnWebSocketConnect public void onConnect(final Session session){
  URI requestUri=session.getUpgradeRequest().getRequestURI();
  logger.info("String_Node_Str" + remoteAddress + "String_Node_Str"+ requestUri);
  remoteAddress=session.getRemoteAddress().toString();
  channelName=extractChannelName(session);
  endpointSender=new JettyWebsocketEndpointSender(remoteAddress,session.getRemote());
  WebSocketEventSubscription subscription=subscriptions.subscribe(channelName,endpointSender);
  new Thread(new SubscriptionDispatchWorker(subscription)).start();
}
Program: 62099
Project: 62099
Buggy source:
@OnWebSocketClose public void onDisconnect(int statusCode,String reason){
  logger.info("String_Node_Str" + remoteAddress + "String_Node_Str"+ statusCode+ "String_Node_Str"+ reason+ "String_Node_Str");
  subscriptionDispatcher.unsubscribe(channelName,endpointSender);
}

Fixed version (ground truth):
@OnWebSocketClose public void onDisconnect(int statusCode,String reason){
  logger.info("String_Node_Str" + remoteAddress + "String_Node_Str"+ statusCode+ "String_Node_Str"+ reason+ "String_Node_Str");
  Optional<WebSocketEventSubscription> optionalSubscription=subscriptions.findSubscriptionForConsumer(channelName,endpointSender);
  if (!optionalSubscription.isPresent()) {
    logger.warn("String_Node_Str" + channelName + "String_Node_Str"+ endpointSender);
    return;
  }
  WebSocketEventSubscription subscription=optionalSubscription.get();
  subscription.getQueue().add(WebsocketEvent.SHUTDOWN);
  subscriptions.unsubscribe(channelName,subscription);
}
Program: 62100
Project: 62100
Buggy source:
@Inject public DataHubWebSocket(SubscriptionDispatcher subscriptionDispatcher){
  this.subscriptionDispatcher=subscriptionDispatcher;
}

Fixed version (ground truth):
@Inject public DataHubWebSocket(SubscriptionRoster subscriptions){
  this.subscriptions=subscriptions;
}
Program: 62101
Project: 62101
Buggy source:
@Inject public JettyWebSocketServlet(SubscriptionDispatcher subscriptionDispatcher){
  this.creator=new CustomWebSocketCreator(subscriptionDispatcher);
}

Fixed version (ground truth):
@Inject public JettyWebSocketServlet(SubscriptionRoster subscriptions){
  this.creator=new CustomWebSocketCreator(subscriptions);
}
Program: 62102
Project: 62102
Buggy source:
public CustomWebSocketCreator(SubscriptionDispatcher subscriptionDispatcher){
  this.subscriptionDispatcher=subscriptionDispatcher;
}

Fixed version (ground truth):
public CustomWebSocketCreator(SubscriptionRoster subscriptions){
  this.subscriptions=subscriptions;
}
Program: 62103
Project: 62103
Buggy source:
@Override public Object createWebSocket(UpgradeRequest req,UpgradeResponse resp){
  return new DataHubWebSocket(subscriptionDispatcher);
}

Fixed version (ground truth):
@Override public Object createWebSocket(UpgradeRequest req,UpgradeResponse resp){
  return new DataHubWebSocket(subscriptions);
}
Program: 62104
Project: 62104
Buggy source:
private Optional<DataHubKey> findFirstDifferentResult(DataHubKey inputKey,QueryResult<OrderedRows<String,String,DataHubCompositeValue>> queryResult){
  OrderedRows<String,String,DataHubCompositeValue> rows=queryResult.get();
  String inputKeyString=keyRenderer.keyToString(inputKey);
  for (  Row<String,String,DataHubCompositeValue> row : rows) {
    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,boolean reversed){
  OrderedRows<String,String,DataHubCompositeValue> rows=queryResult.get();
  List<Row<String,String,DataHubCompositeValue>> rowsList=rows.getList();
  ListIterator<Row<String,String,DataHubCompositeValue>> rowIterator=rowsList.listIterator(reversed ? rowsList.size() : 0);
  String inputKeyString=keyRenderer.keyToString(inputKey);
  while (canIterate(reversed,rowIterator)) {
    Row<String,String,DataHubCompositeValue> row=getRow(reversed,rowIterator);
    ColumnSlice<String,DataHubCompositeValue> columnSlice=row.getColumnSlice();
    Optional<DataHubKey> rowResult=findItemInRow(inputKeyString,columnSlice);
    if (rowResult.isPresent()) {
      return rowResult;
    }
  }
  return Optional.absent();
}
Program: 62105
Project: 62105
Buggy source:
private Optional<DataHubKey> queryAndFindResult(String channelName,DataHubKey key,DataHubKey maxKey,boolean reversed){
  QueryResult<OrderedRows<String,String,DataHubCompositeValue>> queryResult=queryRange(channelName,key,maxKey,reversed);
  return findFirstDifferentResult(key,queryResult);
}

Fixed version (ground truth):
private Optional<DataHubKey> queryAndFindResult(String channelName,DataHubKey key,DataHubKey maxKey,boolean reversed){
  QueryResult<OrderedRows<String,String,DataHubCompositeValue>> queryResult=queryRange(channelName,key,maxKey,reversed);
  return findFirstDifferentResult(key,queryResult,reversed);
}