nus-yam/ex-repair huggingface dataset:
Program: 37650
Project: 37650
Buggy source:
/** 
 * This test verifies what happens if you call lastTrackedOffset() when we have been tracking some offsets. It should return the largest value tracked.
 */
@Test public void testLastStartedOffset(){
  long startingOffset=0L;
  PartitionOffsetManager offsetManager=new PartitionOffsetManager("String_Node_Str",1,startingOffset);
  offsetManager.startOffset(1L);
  offsetManager.startOffset(2L);
  offsetManager.startOffset(3L);
  offsetManager.startOffset(4L);
  assertEquals("String_Node_Str",4L,offsetManager.lastStartedOffset());
  offsetManager.finishOffset(1L);
  long result=offsetManager.lastStartedOffset();
  assertEquals("String_Node_Str",4L,result);
  offsetManager.finishOffset(3L);
  result=offsetManager.lastStartedOffset();
  assertEquals("String_Node_Str",4L,result);
  offsetManager.finishOffset(4L);
  result=offsetManager.lastStartedOffset();
  assertEquals("String_Node_Str",4L,result);
  offsetManager.finishOffset(2L);
  result=offsetManager.lastStartedOffset();
  assertEquals("String_Node_Str",5L,result);
}

Fixed version (ground truth):
/** 
 * This test verifies what happens if you call lastTrackedOffset() when we have been tracking some offsets. It should return the largest value tracked.
 */
@Test public void testLastStartedOffset(){
  long startingOffset=0L;
  PartitionOffsetManager offsetManager=new PartitionOffsetManager("String_Node_Str",1,startingOffset);
  offsetManager.startOffset(1L);
  offsetManager.startOffset(2L);
  offsetManager.startOffset(3L);
  offsetManager.startOffset(4L);
  assertEquals("String_Node_Str",4L,offsetManager.lastStartedOffset());
  offsetManager.finishOffset(1L);
  long result=offsetManager.lastStartedOffset();
  assertEquals("String_Node_Str",4L,result);
  offsetManager.finishOffset(3L);
  result=offsetManager.lastStartedOffset();
  assertEquals("String_Node_Str",4L,result);
  offsetManager.finishOffset(4L);
  result=offsetManager.lastStartedOffset();
  assertEquals("String_Node_Str",4L,result);
  offsetManager.finishOffset(2L);
  result=offsetManager.lastStartedOffset();
  assertEquals("String_Node_Str",4L,result);
}
Program: 37651
Project: 37651
Buggy source:
/** 
 * This test verifies what happens if you call lastTrackedOffset() when we have nothing being tracked. It should return the last finished offset + 1.
 */
@Test public void testLastStartedOffsetWhenHasNone(){
  long startingOffset=0L;
  PartitionOffsetManager offsetManager=new PartitionOffsetManager("String_Node_Str",1,startingOffset);
  assertEquals("String_Node_Str",(startingOffset + 1),offsetManager.lastStartedOffset());
  startingOffset=100L;
  offsetManager=new PartitionOffsetManager("String_Node_Str",1,startingOffset);
  assertEquals("String_Node_Str",(startingOffset + 1),offsetManager.lastStartedOffset());
}

Fixed version (ground truth):
/** 
 * This test verifies what happens if you call lastTrackedOffset() when we have nothing being tracked. It should return the last finished offset + 1.
 */
@Test public void testLastStartedOffsetWhenHasNone(){
  long startingOffset=0L;
  PartitionOffsetManager offsetManager=new PartitionOffsetManager("String_Node_Str",1,startingOffset);
  assertEquals("String_Node_Str",startingOffset,offsetManager.lastStartedOffset());
  startingOffset=100L;
  offsetManager=new PartitionOffsetManager("String_Node_Str",1,startingOffset);
  assertEquals("String_Node_Str",startingOffset,offsetManager.lastStartedOffset());
}
Program: 37654
Project: 37654
Buggy source:
private String getSidelineRequestStateKey(final SidelineRequestIdentifier id,final int partitionId){
  return id.toString().concat("String_Node_Str").concat(String.valueOf(partitionId));
}

Fixed version (ground truth):
private SidelineRequestStateKey getSidelineRequestStateKey(final SidelineRequestIdentifier id,final int partitionId){
  return new SidelineRequestStateKey(id,partitionId);
}
Program: 37655
Project: 37655
Buggy source:
/** 
 * @return - The full zookeeper path to where our consumer state is stored.
 */
String getZkRequestStatePath(final String sidelineIdentifierStr,final int partitionId){
  return getZkRoot() + "String_Node_Str" + sidelineIdentifierStr+ "String_Node_Str"+ partitionId;
}

Fixed version (ground truth):
/** 
 * @return - The full zookeeper path to where our consumer state is stored.
 */
String getZkRequestStatePath(final String sidelineIdentifierStr,final int partitionId){
  return getZkRequestStatePath(sidelineIdentifierStr) + "String_Node_Str" + partitionId;
}
Program: 37656
Project: 37656
Buggy source:
/** 
 * @return returns a new instance of the configured deserializer.
 */
public synchronized Deserializer createNewDeserializerInstance(){
  if (deserializerClass == null) {
    final String classStr=(String)topologyConfig.get(SidelineSpoutConfig.DESERIALIZER_CLASS);
    if (Strings.isNullOrEmpty(classStr)) {
      throw new IllegalStateException("String_Node_Str" + SidelineSpoutConfig.DESERIALIZER_CLASS);
    }
    try {
      deserializerClass=(Class<? extends Deserializer>)Class.forName(classStr);
    }
 catch (    ClassNotFoundException e) {
      throw new RuntimeException(e);
    }
  }
  try {
    return deserializerClass.newInstance();
  }
 catch (  IllegalAccessException|InstantiationException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
/** 
 * @return returns a new instance of the configured deserializer.
 */
public synchronized Deserializer createNewDeserializerInstance(){
  if (deserializerClass == null) {
    final String classStr=(String)spoutConfig.get(SidelineSpoutConfig.DESERIALIZER_CLASS);
    if (Strings.isNullOrEmpty(classStr)) {
      throw new IllegalStateException("String_Node_Str" + SidelineSpoutConfig.DESERIALIZER_CLASS);
    }
    try {
      deserializerClass=(Class<? extends Deserializer>)Class.forName(classStr);
    }
 catch (    ClassNotFoundException e) {
      throw new RuntimeException(e);
    }
  }
  try {
    return deserializerClass.newInstance();
  }
 catch (  IllegalAccessException|InstantiationException e) {
    throw new RuntimeException(e);
  }
}
Program: 37657
Project: 37657
Buggy source:
/** 
 * @return returns a new instance of the configured Metrics Recorder manager.
 */
public synchronized MetricsRecorder createNewMetricsRecorder(){
  if (metricsRecorderClass == null) {
    String classStr=(String)topologyConfig.get(SidelineSpoutConfig.METRICS_RECORDER_CLASS);
    if (Strings.isNullOrEmpty(classStr)) {
      throw new IllegalStateException("String_Node_Str" + SidelineSpoutConfig.METRICS_RECORDER_CLASS);
    }
    try {
      metricsRecorderClass=(Class<? extends MetricsRecorder>)Class.forName(classStr);
    }
 catch (    ClassNotFoundException e) {
      throw new RuntimeException(e);
    }
  }
  try {
    return metricsRecorderClass.newInstance();
  }
 catch (  IllegalAccessException|InstantiationException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
/** 
 * @return returns a new instance of the configured Metrics Recorder manager.
 */
public synchronized MetricsRecorder createNewMetricsRecorder(){
  if (metricsRecorderClass == null) {
    String classStr=(String)spoutConfig.get(SidelineSpoutConfig.METRICS_RECORDER_CLASS);
    if (Strings.isNullOrEmpty(classStr)) {
      throw new IllegalStateException("String_Node_Str" + SidelineSpoutConfig.METRICS_RECORDER_CLASS);
    }
    try {
      metricsRecorderClass=(Class<? extends MetricsRecorder>)Class.forName(classStr);
    }
 catch (    ClassNotFoundException e) {
      throw new RuntimeException(e);
    }
  }
  try {
    return metricsRecorderClass.newInstance();
  }
 catch (  IllegalAccessException|InstantiationException e) {
    throw new RuntimeException(e);
  }
}
Program: 37658
Project: 37658
Buggy source:
/** 
 * @return returns a new instance of the configured persistence manager.
 */
public synchronized PersistenceAdapter createNewPersistenceAdapterInstance(){
  if (persistenceAdapterClass == null) {
    final String classStr=(String)topologyConfig.get(SidelineSpoutConfig.PERSISTENCE_ADAPTER_CLASS);
    if (Strings.isNullOrEmpty(classStr)) {
      throw new IllegalStateException("String_Node_Str" + SidelineSpoutConfig.PERSISTENCE_ADAPTER_CLASS);
    }
    try {
      persistenceAdapterClass=(Class<? extends PersistenceAdapter>)Class.forName(classStr);
    }
 catch (    ClassNotFoundException e) {
      throw new RuntimeException(e);
    }
  }
  try {
    return persistenceAdapterClass.newInstance();
  }
 catch (  IllegalAccessException|InstantiationException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
/** 
 * @return returns a new instance of the configured persistence manager.
 */
public synchronized PersistenceAdapter createNewPersistenceAdapterInstance(){
  if (persistenceAdapterClass == null) {
    final String classStr=(String)spoutConfig.get(SidelineSpoutConfig.PERSISTENCE_ADAPTER_CLASS);
    if (Strings.isNullOrEmpty(classStr)) {
      throw new IllegalStateException("String_Node_Str" + SidelineSpoutConfig.PERSISTENCE_ADAPTER_CLASS);
    }
    try {
      persistenceAdapterClass=(Class<? extends PersistenceAdapter>)Class.forName(classStr);
    }
 catch (    ClassNotFoundException e) {
      throw new RuntimeException(e);
    }
  }
  try {
    return persistenceAdapterClass.newInstance();
  }
 catch (  IllegalAccessException|InstantiationException e) {
    throw new RuntimeException(e);
  }
}
Program: 37659
Project: 37659
Buggy source:
/** 
 * @return returns a new instance of the configured RetryManager.
 */
public synchronized RetryManager createNewFailedMsgRetryManagerInstance(){
  if (failedMsgRetryManagerClass == null) {
    String classStr=(String)topologyConfig.get(SidelineSpoutConfig.RETRY_MANAGER_CLASS);
    if (Strings.isNullOrEmpty(classStr)) {
      throw new IllegalStateException("String_Node_Str" + SidelineSpoutConfig.TUPLE_BUFFER_CLASS);
    }
    try {
      failedMsgRetryManagerClass=(Class<? extends RetryManager>)Class.forName(classStr);
    }
 catch (    ClassNotFoundException e) {
      throw new RuntimeException(e);
    }
  }
  try {
    return failedMsgRetryManagerClass.newInstance();
  }
 catch (  IllegalAccessException|InstantiationException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
/** 
 * @return returns a new instance of the configured RetryManager.
 */
public synchronized RetryManager createNewFailedMsgRetryManagerInstance(){
  if (failedMsgRetryManagerClass == null) {
    String classStr=(String)spoutConfig.get(SidelineSpoutConfig.RETRY_MANAGER_CLASS);
    if (Strings.isNullOrEmpty(classStr)) {
      throw new IllegalStateException("String_Node_Str" + SidelineSpoutConfig.TUPLE_BUFFER_CLASS);
    }
    try {
      failedMsgRetryManagerClass=(Class<? extends RetryManager>)Class.forName(classStr);
    }
 catch (    ClassNotFoundException e) {
      throw new RuntimeException(e);
    }
  }
  try {
    return failedMsgRetryManagerClass.newInstance();
  }
 catch (  IllegalAccessException|InstantiationException e) {
    throw new RuntimeException(e);
  }
}
Program: 37660
Project: 37660
Buggy source:
/** 
 * @return returns a new instance of the configured TupleBuffer interface.
 */
public synchronized TupleBuffer createNewTupleBufferInstance(){
  if (tupleBufferClass == null) {
    String classStr=(String)topologyConfig.get(SidelineSpoutConfig.TUPLE_BUFFER_CLASS);
    if (Strings.isNullOrEmpty(classStr)) {
      throw new IllegalStateException("String_Node_Str" + SidelineSpoutConfig.TUPLE_BUFFER_CLASS);
    }
    try {
      tupleBufferClass=(Class<? extends TupleBuffer>)Class.forName(classStr);
    }
 catch (    ClassNotFoundException e) {
      throw new RuntimeException(e);
    }
  }
  try {
    return tupleBufferClass.newInstance();
  }
 catch (  IllegalAccessException|InstantiationException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
/** 
 * @return returns a new instance of the configured TupleBuffer interface.
 */
public synchronized TupleBuffer createNewTupleBufferInstance(){
  if (tupleBufferClass == null) {
    String classStr=(String)spoutConfig.get(SidelineSpoutConfig.TUPLE_BUFFER_CLASS);
    if (Strings.isNullOrEmpty(classStr)) {
      throw new IllegalStateException("String_Node_Str" + SidelineSpoutConfig.TUPLE_BUFFER_CLASS);
    }
    try {
      tupleBufferClass=(Class<? extends TupleBuffer>)Class.forName(classStr);
    }
 catch (    ClassNotFoundException e) {
      throw new RuntimeException(e);
    }
  }
  try {
    return tupleBufferClass.newInstance();
  }
 catch (  IllegalAccessException|InstantiationException e) {
    throw new RuntimeException(e);
  }
}
Program: 37661
Project: 37661
Buggy source:
public FactoryManager(Map topologyConfig){
  this.topologyConfig=Tools.immutableCopy(topologyConfig);
}

Fixed version (ground truth):
public FactoryManager(Map spoutConfig){
  this.spoutConfig=Tools.immutableCopy(spoutConfig);
}
Program: 37662
Project: 37662
Buggy source:
/** 
 * Generates a VirtualSpoutId using an optional postfix.  It also appends the Task index id.  This will probably cause problems if you decrease the number of instances of the spout.
 * @param id - Id to add after the prefix
 * @return - Generates VirtualSpoutId.
 */
String generateVirtualSpoutId(final String id){
  if (Strings.isNullOrEmpty(id)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  String newId=(String)getTopologyConfigItem(SidelineSpoutConfig.CONSUMER_ID_PREFIX);
  newId+="String_Node_Str" + id;
  return newId;
}

Fixed version (ground truth):
/** 
 * Generates a VirtualSpoutId using an optional postfix.  It also appends the Task index id.  This will probably cause problems if you decrease the number of instances of the spout.
 * @param id - Id to add after the prefix
 * @return - Generates VirtualSpoutId.
 */
String generateVirtualSpoutId(final String id){
  if (Strings.isNullOrEmpty(id)) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  String newId=(String)getSpoutConfigItem(SidelineSpoutConfig.CONSUMER_ID_PREFIX);
  newId+="String_Node_Str" + id;
  return newId;
}
Program: 37663
Project: 37663
Buggy source:
/** 
 * Open a virtual spout (like when a sideline stop request is made)
 * @param id Id of the sideline request
 * @param step Filter chain step (it will be negate)
 * @param startingState Starting consumer state
 * @param endingState Ending consumer state
 */
private void openVirtualSpout(final SidelineRequestIdentifier id,final FilterChainStep step,final ConsumerState startingState,final ConsumerState endingState){
  final String virtualSpoutId=generateVirtualSpoutId(id.toString());
  logger.debug("String_Node_Str",virtualSpoutId,startingState,endingState);
  final VirtualSpout spout=new VirtualSpout(getTopologyConfig(),getTopologyContext(),getFactoryManager(),startingState,endingState);
  spout.setVirtualSpoutId(virtualSpoutId);
  spout.setSidelineRequestIdentifier(id);
  spout.getFilterChain().addStep(id,new NegatingFilterChainStep(step));
  getCoordinator().addSidelineSpout(spout);
}

Fixed version (ground truth):
/** 
 * Open a virtual spout (like when a sideline stop request is made)
 * @param id Id of the sideline request
 * @param step Filter chain step (it will be negate)
 * @param startingState Starting consumer state
 * @param endingState Ending consumer state
 */
private void openVirtualSpout(final SidelineRequestIdentifier id,final FilterChainStep step,final ConsumerState startingState,final ConsumerState endingState){
  final String virtualSpoutId=generateVirtualSpoutId(id.toString());
  logger.debug("String_Node_Str",virtualSpoutId,startingState,endingState);
  final VirtualSpout spout=new VirtualSpout(getSpoutConfig(),getTopologyContext(),getFactoryManager(),startingState,endingState);
  spout.setVirtualSpoutId(virtualSpoutId);
  spout.setSidelineRequestIdentifier(id);
  spout.getFilterChain().addStep(id,new NegatingFilterChainStep(step));
  getCoordinator().addSidelineSpout(spout);
}
Program: 37664
Project: 37664
Buggy source:
/** 
 * Constructor to create our SidelineSpout.
 * @TODO this method arguments may change to an actual SidelineSpoutConfig object instead of a generic map?
 * @param topologyConfig - Our configuration.
 */
public SidelineSpout(Map topologyConfig){
  this.topologyConfig=Collections.unmodifiableMap(SidelineSpoutConfig.setDefaults(topologyConfig));
  factoryManager=new FactoryManager(getTopologyConfig());
}

Fixed version (ground truth):
/** 
 * Constructor to create our SidelineSpout.
 * @TODO this method arguments may change to an actual SidelineSpoutConfig object instead of a generic map?
 * @param spoutConfig - Our configuration.
 */
public SidelineSpout(Map spoutConfig){
  this.spoutConfig=Collections.unmodifiableMap(SidelineSpoutConfig.setDefaults(spoutConfig));
  factoryManager=new FactoryManager(getSpoutConfig());
}
Program: 37665
Project: 37665
Buggy source:
/** 
 * @return - returns the stream that tuples will be emitted out.
 */
String getOutputStreamId(){
  if (outputStreamId == null) {
    if (topologyConfig == null) {
      throw new IllegalStateException("String_Node_Str");
    }
    outputStreamId=(String)getTopologyConfigItem(SidelineSpoutConfig.OUTPUT_STREAM_ID);
    if (Strings.isNullOrEmpty(outputStreamId)) {
      outputStreamId=Utils.DEFAULT_STREAM_ID;
    }
  }
  return outputStreamId;
}

Fixed version (ground truth):
/** 
 * @return - returns the stream that tuples will be emitted out.
 */
String getOutputStreamId(){
  if (outputStreamId == null) {
    if (spoutConfig == null) {
      throw new IllegalStateException("String_Node_Str");
    }
    outputStreamId=(String)getSpoutConfigItem(SidelineSpoutConfig.OUTPUT_STREAM_ID);
    if (Strings.isNullOrEmpty(outputStreamId)) {
      outputStreamId=Utils.DEFAULT_STREAM_ID;
    }
  }
  return outputStreamId;
}
Program: 37667
Project: 37667
Buggy source:
public void open(Map topologyConfig){
  persistenceAdapter.open(topologyConfig);
}

Fixed version (ground truth):
public void open(Map spoutConfig){
  persistenceAdapter.open(spoutConfig);
}
Program: 37668
Project: 37668
Buggy source:
/** 
 * For testing only! Constructor used in testing to inject SidelineConsumer instance.
 */
protected VirtualSpout(Map topologyConfig,TopologyContext topologyContext,FactoryManager factoryManager,Consumer consumer,ConsumerState startingState,ConsumerState endingState){
  this(topologyConfig,topologyContext,factoryManager,startingState,endingState);
  this.consumer=consumer;
}

Fixed version (ground truth):
/** 
 * For testing only! Constructor used in testing to inject SidelineConsumer instance.
 */
protected VirtualSpout(Map spoutConfig,TopologyContext topologyContext,FactoryManager factoryManager,Consumer consumer,ConsumerState startingState,ConsumerState endingState){
  this(spoutConfig,topologyContext,factoryManager,startingState,endingState);
  this.consumer=consumer;
}
Program: 37670
Project: 37670
Buggy source:
/** 
 * Called to initialize this implementation.
 * @param stormConfig - not used, at least for now.
 */
public void open(Map stormConfig){
  if (stormConfig.containsKey(SidelineSpoutConfig.FAILED_MSG_RETRY_MANAGER_MAX_RETRIES)) {
    maxRetries=((Number)stormConfig.get(SidelineSpoutConfig.FAILED_MSG_RETRY_MANAGER_MAX_RETRIES)).intValue();
  }
  if (stormConfig.containsKey(SidelineSpoutConfig.FAILED_MSG_RETRY_MANAGER_MIN_RETRY_TIME_MS)) {
    minRetryTimeMs=((Number)stormConfig.get(SidelineSpoutConfig.FAILED_MSG_RETRY_MANAGER_MIN_RETRY_TIME_MS)).longValue();
  }
  retriesInFlight=Sets.newHashSet();
  numberOfTimesFailed=Maps.newHashMap();
  failedMessageIds=Maps.newTreeMap();
}

Fixed version (ground truth):
/** 
 * Called to initialize this implementation.
 * @param spoutConfig - not used, at least for now.
 */
public void open(Map spoutConfig){
  if (spoutConfig.containsKey(SidelineSpoutConfig.FAILED_MSG_RETRY_MANAGER_MAX_RETRIES)) {
    maxRetries=((Number)spoutConfig.get(SidelineSpoutConfig.FAILED_MSG_RETRY_MANAGER_MAX_RETRIES)).intValue();
  }
  if (spoutConfig.containsKey(SidelineSpoutConfig.FAILED_MSG_RETRY_MANAGER_MIN_RETRY_TIME_MS)) {
    minRetryTimeMs=((Number)spoutConfig.get(SidelineSpoutConfig.FAILED_MSG_RETRY_MANAGER_MIN_RETRY_TIME_MS)).longValue();
  }
  retriesInFlight=Sets.newHashSet();
  numberOfTimesFailed=Maps.newHashMap();
  failedMessageIds=Maps.newTreeMap();
}
Program: 37671
Project: 37671
Buggy source:
@Override public void open(Map stormConfig){
  messageIdsInFlight=Sets.newHashSet();
  failedMessageIds=new LinkedList<>();
}

Fixed version (ground truth):
@Override public void open(Map spoutConfig){
  messageIdsInFlight=Sets.newHashSet();
  failedMessageIds=new LinkedList<>();
}
Program: 37672
Project: 37672
Buggy source:
@Override public void open(Map stormConfig){
}

Fixed version (ground truth):
@Override public void open(Map spoutConfig){
}
Program: 37673
Project: 37673
Buggy source:
/** 
 * Initialization.
 */
void open(Map stormConfig);

Fixed version (ground truth):
/** 
 * Initialization.
 */
void open(Map spoutConfig);
Program: 37674
Project: 37674
Buggy source:
/** 
 * @return - the maximum amount of concurrently running VirtualSpouts we'll start.
 */
int getMaxConcurrentVirtualSpouts(){
  return (int)getTopologyConfig().get(SidelineSpoutConfig.MAX_CONCURRENT_VIRTUAL_SPOUTS);
}

Fixed version (ground truth):
/** 
 * @return - the maximum amount of concurrently running VirtualSpouts we'll start.
 */
int getMaxConcurrentVirtualSpouts(){
  return ((Number)getTopologyConfig().get(SidelineSpoutConfig.MAX_CONCURRENT_VIRTUAL_SPOUTS)).intValue();
}
Program: 37675
Project: 37675
Buggy source:
/** 
 * Called to initialize this implementation.
 * @param stormConfig - not used, at least for now.
 */
public void open(Map stormConfig){
  if (stormConfig.containsKey(SidelineSpoutConfig.FAILED_MSG_RETRY_MANAGER_MAX_RETRIES)) {
    maxRetries=(int)stormConfig.get(SidelineSpoutConfig.FAILED_MSG_RETRY_MANAGER_MAX_RETRIES);
  }
  if (stormConfig.containsKey(SidelineSpoutConfig.FAILED_MSG_RETRY_MANAGER_MIN_RETRY_TIME_MS)) {
    minRetryTimeMs=(long)stormConfig.get(SidelineSpoutConfig.FAILED_MSG_RETRY_MANAGER_MIN_RETRY_TIME_MS);
  }
  retriesInFlight=Sets.newHashSet();
  numberOfTimesFailed=Maps.newHashMap();
  failedMessageIds=Maps.newTreeMap();
}

Fixed version (ground truth):
/** 
 * Called to initialize this implementation.
 * @param stormConfig - not used, at least for now.
 */
public void open(Map stormConfig){
  if (stormConfig.containsKey(SidelineSpoutConfig.FAILED_MSG_RETRY_MANAGER_MAX_RETRIES)) {
    maxRetries=((Number)stormConfig.get(SidelineSpoutConfig.FAILED_MSG_RETRY_MANAGER_MAX_RETRIES)).intValue();
  }
  if (stormConfig.containsKey(SidelineSpoutConfig.FAILED_MSG_RETRY_MANAGER_MIN_RETRY_TIME_MS)) {
    minRetryTimeMs=(long)stormConfig.get(SidelineSpoutConfig.FAILED_MSG_RETRY_MANAGER_MIN_RETRY_TIME_MS);
  }
  retriesInFlight=Sets.newHashSet();
  numberOfTimesFailed=Maps.newHashMap();
  failedMessageIds=Maps.newTreeMap();
}
Program: 37676
Project: 37676
Buggy source:
/** 
 * Not thread safe.
 * @return
 */
public long lastFinishedOffset(){
  return lastFinishedOffset;
}

Fixed version (ground truth):
/** 
 * Not thread safe.
 * @return - return the last offset considered "finished".Here a "finished" offset is the highest continuous offset.
 */
public long lastFinishedOffset(){
  return lastFinishedOffset;
}
Program: 37677
Project: 37677
Buggy source:
/** 
 * Internal method used to fill internal message buffer from kafka. Maybe this should be marked private.
 */
public void fillBuffer(){
  if (buffer == null || !bufferIterator.hasNext()) {
    buffer=kafkaConsumer.poll(3000);
    bufferIterator=buffer.iterator();
  }
}

Fixed version (ground truth):
/** 
 * Internal method used to fill internal message buffer from kafka. Maybe this should be marked private.
 */
public void fillBuffer(){
  if (buffer == null || !bufferIterator.hasNext()) {
    try {
      buffer=kafkaConsumer.poll(3000);
    }
 catch (    OffsetOutOfRangeException outOfRangeException) {
      handleOffsetOutOfRange(outOfRangeException);
      buffer=null;
      bufferIterator=null;
      fillBuffer();
      return;
    }
    bufferIterator=buffer.iterator();
  }
}
Program: 37679
Project: 37679
Buggy source:
/** 
 * Creates and starts ZooKeeper and Kafka server instances.
 * @throws Exception
 */
public void start() throws Exception {
  InstanceSpec zkInstanceSpec=new InstanceSpec(null,21811,-1,-1,true,-1,-1,1000);
  zkServer=new TestingServer(zkInstanceSpec,true);
  String connectionString=getZkServer().getConnectString();
  File logDir=new File("String_Node_Str" + Double.toHexString(Math.random()));
  String kafkaPort=String.valueOf(InstanceSpec.getRandomPort());
  Properties p=new Properties();
  p.setProperty("String_Node_Str",connectionString);
  p.setProperty("String_Node_Str",String.valueOf(new Random().nextInt(Integer.MAX_VALUE)));
  p.setProperty("String_Node_Str",kafkaPort);
  p.setProperty("String_Node_Str",logDir.getAbsolutePath());
  p.setProperty("String_Node_Str","String_Node_Str");
  p.setProperty("String_Node_Str","String_Node_Str");
  p.setProperty("String_Node_Str",kafkaPort);
  p.setProperty("String_Node_Str","String_Node_Str");
  p.setProperty("String_Node_Str","String_Node_Str");
  p.setProperty("String_Node_Str","String_Node_Str");
  KafkaConfig config=new KafkaConfig(p);
  kafka=new KafkaServerStartable(config);
  getKafkaServer().startup();
  cli=CuratorFrameworkFactory.newClient(getZkServer().getConnectString(),new RetryOneTime(2000));
}

Fixed version (ground truth):
/** 
 * Creates and starts ZooKeeper and Kafka server instances.
 * @throws Exception
 */
public void start() throws Exception {
  InstanceSpec zkInstanceSpec=new InstanceSpec(null,21811,-1,-1,true,-1,-1,1000);
  zkServer=new TestingServer(zkInstanceSpec,true);
  String connectionString=getZkServer().getConnectString();
  File logDir=new File("String_Node_Str" + Double.toHexString(Math.random()));
  String kafkaPort=String.valueOf(InstanceSpec.getRandomPort());
  Properties p=new Properties();
  p.setProperty("String_Node_Str",connectionString);
  p.setProperty("String_Node_Str",kafkaPort);
  p.setProperty("String_Node_Str",logDir.getAbsolutePath());
  p.setProperty("String_Node_Str","String_Node_Str");
  p.setProperty("String_Node_Str","String_Node_Str");
  p.setProperty("String_Node_Str",kafkaPort);
  p.setProperty("String_Node_Str","String_Node_Str");
  p.setProperty("String_Node_Str","String_Node_Str");
  p.setProperty("String_Node_Str","String_Node_Str");
  KafkaConfig config=new KafkaConfig(p);
  kafka=new KafkaServerStartable(config);
  getKafkaServer().startup();
  cli=CuratorFrameworkFactory.newClient(getZkServer().getConnectString(),new RetryOneTime(2000));
}
Program: 37680
Project: 37680
Buggy source:
/** 
 * Start the filter of tracking this offset Not thread safe
 * @param offset
 */
public void startOffset(long offset){
  trackedOffsets.add(offset);
  if (offset > lastStartedOffset) {
    lastStartedOffset=offset;
  }
 else {
    logger.warn("String_Node_Str",lastStartedOffset,offset);
  }
}

Fixed version (ground truth):
/** 
 * Start the filter of tracking this offset Not thread safe
 * @param offset
 */
public void startOffset(long offset){
  trackedOffsets.add(offset);
  if (offset >= lastStartedOffset) {
    lastStartedOffset=offset;
  }
 else {
    logger.warn("String_Node_Str",lastStartedOffset,offset);
  }
}
Program: 37681
Project: 37681
Buggy source:
/** 
 * Internal method that given a collection of topic partitions will find the earliest offset for that partition, seek the underlying consumer to it, and reset its internal offset tracking to that new position. This should be used when no state exists for a given partition, OR if the offset requested was too old.
 * @param topicPartitions - the collection of offsets to reset offsets for to the earliest position.
 */
private void resetPartitionsToEarliest(Collection<TopicPartition> topicPartitions){
  logger.info("String_Node_Str",topicPartitions);
  getKafkaConsumer().seekToBeginning(topicPartitions);
  for (  TopicPartition topicPartition : topicPartitions) {
    final long newOffset=getKafkaConsumer().position(topicPartition);
    logger.info("String_Node_Str",topicPartition,newOffset);
    partitionStateManagers.put(topicPartition,new PartitionOffsetManager(topicPartition.topic(),topicPartition.partition(),newOffset));
  }
  logger.info("String_Node_Str",getKafkaConsumer().assignment());
}

Fixed version (ground truth):
/** 
 * Internal method that given a collection of topic partitions will find the earliest offset for that partition, seek the underlying consumer to it, and reset its internal offset tracking to that new position. This should be used when no state exists for a given partition, OR if the offset requested was too old.
 * @param topicPartitions - the collection of offsets to reset offsets for to the earliest position.
 */
private void resetPartitionsToEarliest(Collection<TopicPartition> topicPartitions){
  logger.info("String_Node_Str",topicPartitions);
  getKafkaConsumer().seekToBeginning(topicPartitions);
  for (  TopicPartition topicPartition : topicPartitions) {
    final long newOffset=getKafkaConsumer().position(topicPartition) - 1;
    logger.info("String_Node_Str",topicPartition,newOffset);
    partitionStateManagers.put(topicPartition,new PartitionOffsetManager(topicPartition.topic(),topicPartition.partition(),newOffset));
  }
  logger.info("String_Node_Str",getKafkaConsumer().assignment());
}
Program: 37683
Project: 37683
Buggy source:
private SidelineConsumerConfig getDefaultSidelineConsumerConfig(final String topicName){
  List<String> brokerHosts=Lists.newArrayList(kafkaTestServer.getKafkaServer().serverConfig().advertisedHostName() + "String_Node_Str" + kafkaTestServer.getKafkaServer().serverConfig().advertisedPort());
  SidelineConsumerConfig config=new SidelineConsumerConfig(brokerHosts,"String_Node_Str",topicName);
  config.setKafkaConsumerProperty("String_Node_Str","String_Node_Str");
  return config;
}

Fixed version (ground truth):
private SidelineConsumerConfig getDefaultSidelineConsumerConfig(final String topicName){
  List<String> brokerHosts=Lists.newArrayList(kafkaTestServer.getKafkaServer().serverConfig().advertisedHostName() + "String_Node_Str" + kafkaTestServer.getKafkaServer().serverConfig().advertisedPort());
  SidelineConsumerConfig config=new SidelineConsumerConfig(brokerHosts,"String_Node_Str",topicName);
  return config;
}
Program: 37684
Project: 37684
Buggy source:
/** 
 * Tests the constructor saves off instances of things passed into it properly.
 */
@Test public void testConstructor(){
  List<String> brokerHosts=Lists.newArrayList(kafkaTestServer.getKafkaServer().serverConfig().advertisedHostName() + "String_Node_Str" + kafkaTestServer.getKafkaServer().serverConfig().advertisedPort());
  final SidelineConsumerConfig config=new SidelineConsumerConfig(brokerHosts,"String_Node_Str",topicName);
  config.setKafkaConsumerProperty("String_Node_Str","String_Node_Str");
  PersistenceManager persistenceManager=new InMemoryPersistenceManager();
  persistenceManager.open(Maps.newHashMap());
  SidelineConsumer sidelineConsumer=new SidelineConsumer(config,persistenceManager);
  assertNotNull("String_Node_Str",sidelineConsumer.getConsumerConfig());
  assertEquals(config,sidelineConsumer.getConsumerConfig());
  assertNotNull("String_Node_Str",sidelineConsumer.getPersistenceManager());
  assertEquals(persistenceManager,sidelineConsumer.getPersistenceManager());
}

Fixed version (ground truth):
/** 
 * Tests the constructor saves off instances of things passed into it properly.
 */
@Test public void testConstructor(){
  final SidelineConsumerConfig config=getDefaultSidelineConsumerConfig(topicName);
  PersistenceManager persistenceManager=new InMemoryPersistenceManager();
  persistenceManager.open(Maps.newHashMap());
  SidelineConsumer sidelineConsumer=new SidelineConsumer(config,persistenceManager);
  assertNotNull("String_Node_Str",sidelineConsumer.getConsumerConfig());
  assertEquals(config,sidelineConsumer.getConsumerConfig());
  assertNotNull("String_Node_Str",sidelineConsumer.getPersistenceManager());
  assertEquals(persistenceManager,sidelineConsumer.getPersistenceManager());
}
Program: 37694
Project: 37694
Buggy source:
/** 
 * Starts a sideline request
 * @param startRequest A representation of the request that is being started
 */
public SidelineIdentifier startSidelining(StartRequest startRequest){
  logger.info("String_Node_Str");
  final SidelineIdentifier id=new SidelineIdentifier();
  final ConsumerState startingState=fireHoseSpout.getCurrentState();
  for (  TopicPartition topicPartition : startingState.getTopicPartitions()) {
    startingState.setOffset(topicPartition,startingState.getOffsetForTopicAndPartition(topicPartition) + 1);
  }
  persistenceManager.persistSidelineRequestState(id,startingState);
  fireHoseSpout.getFilterChain().addSteps(id,startRequest.steps);
  startingTrigger.start(id);
  metricsRecorder.count(getClass(),"String_Node_Str",1L);
  return id;
}

Fixed version (ground truth):
/** 
 * Starts a sideline request
 * @param startRequest A representation of the request that is being started
 */
public SidelineIdentifier startSidelining(StartRequest startRequest){
  logger.info("String_Node_Str");
  final SidelineIdentifier id=new SidelineIdentifier();
  final ConsumerState startingState=fireHoseSpout.getCurrentState();
  persistenceManager.persistSidelineRequestState(id,startingState);
  fireHoseSpout.getFilterChain().addSteps(id,startRequest.steps);
  startingTrigger.start(id);
  metricsRecorder.count(getClass(),"String_Node_Str",1L);
  return id;
}
Program: 37696
Project: 37696
Buggy source:
@Override public ConsumerState retrieveConsumerState(final String consumerId){
  verifyHasBeenOpened();
  Map<Object,Object> json=readJSON(getZkConsumerStatePath(consumerId));
  logger.info("String_Node_Str",json);
  return parseJsonToConsumerState(json);
}

Fixed version (ground truth):
@Override public ConsumerState retrieveConsumerState(final String consumerId){
  verifyHasBeenOpened();
  final String path=getZkConsumerStatePath(consumerId);
  Map<Object,Object> json=readJSON(path);
  logger.info("String_Node_Str",path,json);
  return parseJsonToConsumerState(json);
}
Program: 37697
Project: 37697
Buggy source:
@Override public ConsumerState retrieveSidelineRequestState(SidelineIdentifier id){
  verifyHasBeenOpened();
  Map<Object,Object> json=readJSON(getZkRequestStatePath(id.toString()));
  logger.info("String_Node_Str",json);
  return parseJsonToConsumerState(json);
}

Fixed version (ground truth):
@Override public ConsumerState retrieveSidelineRequestState(SidelineIdentifier id){
  verifyHasBeenOpened();
  final String path=getZkRequestStatePath(id.toString());
  Map<Object,Object> json=readJSON(path);
  logger.info("String_Node_Str",path,json);
  return parseJsonToConsumerState(json);
}
Program: 37698
Project: 37698
Buggy source:
/** 
 * TODO Calculate the start date and range of dates for the full 7 day week from Sunday to Saturday. Hint: Look at   {@link LocalDate#with(TemporalAdjuster)}Hint: Look at   {@link TemporalAdjusters#previousOrSame(DayOfWeek)}Hint: Look at   {@link LocalDate#plusDays(long)}Hint: Look at   {@link LocalDateRange#of(LocalDate,LocalDate)}Hint: The end date is exclusive in LocalDateRange
 */
public WorkWeek(LocalDate forDate,SortedSetMultimap<LocalDate,Meeting> calendarMeetings){
  LocalDate start=null;
  this.range=null;
  this.meetings=calendarMeetings.selectKeysValues((date,meeting) -> this.range.contains(date));
}

Fixed version (ground truth):
/** 
 * TODO Calculate the start date and range of dates for the 5 day week from Monday to Friday. Hint: Look at   {@link LocalDate#with(TemporalAdjuster)}Hint: Look at   {@link TemporalAdjusters#previousOrSame(DayOfWeek)}Hint: Look at   {@link LocalDate#plusDays(long)}Hint: Look at   {@link LocalDateRange#of(LocalDate,LocalDate)}Hint: The end date is exclusive in LocalDateRange
 */
public WorkWeek(LocalDate forDate,SortedSetMultimap<LocalDate,Meeting> calendarMeetings){
  LocalDate start=null;
  this.range=null;
  this.meetings=calendarMeetings.selectKeysValues((date,meeting) -> this.range.contains(date));
}
Program: 37699
Project: 37699
Buggy source:
/** 
 * TODO Calculate the start date and range of dates for the full 7 day week from Sunday to Saturday. Hint: Look at   {@link LocalDate#with(TemporalAdjuster)}Hint: Look at   {@link TemporalAdjusters#previousOrSame(DayOfWeek)}Hint: Look at   {@link LocalDate#plusDays(long)}Hint: Look at   {@link LocalDateRange#of(LocalDate,LocalDate)}Hint: The end date is exclusive in LocalDateRange
 */
public WorkWeek(LocalDate forDate,SortedSetMultimap<LocalDate,Meeting> calendarMeetings){
  LocalDate start=null;
  this.range=null;
  this.meetings=calendarMeetings.selectKeysValues((date,meeting) -> this.range.contains(date));
}

Fixed version (ground truth):
/** 
 * TODO Calculate the start date and range of dates for the 5 day week from Monday to Friday. Hint: Look at   {@link LocalDate#with(TemporalAdjuster)}Hint: Look at   {@link TemporalAdjusters#previousOrSame(DayOfWeek)}Hint: Look at   {@link LocalDate#plusDays(long)}Hint: Look at   {@link LocalDateRange#of(LocalDate,LocalDate)}Hint: The end date is exclusive in LocalDateRange
 */
public WorkWeek(LocalDate forDate,SortedSetMultimap<LocalDate,Meeting> calendarMeetings){
  LocalDate start=null;
  this.range=null;
  this.meetings=calendarMeetings.selectKeysValues((date,meeting) -> this.range.contains(date));
}
Program: 37700
Project: 37700
Buggy source:
@Test public void function(){
  var toUppercase=new Function<String,String>(){
    @Override public String apply(    String s){
      return s.toUpperCase();
    }
  }
;
  Assert.assertEquals("String_Node_Str",toUppercase.apply("String_Node_Str"));
  List<String> lowercase=List.of("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  List<String> uppercase=lowercase.stream().map(toUppercase).collect(Collectors.toList());
  Assert.assertEquals(List.of("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),uppercase);
}

Fixed version (ground truth):
@Test public void function(){
  var toUppercase=new Function<String,String>(){
    @Override public String apply(    String s){
      return s.toUpperCase();
    }
  }
;
  Assert.assertEquals("String_Node_Str",toUppercase.apply("String_Node_Str"));
  List<String> lowercase=List.of("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  Set<String> uppercase=lowercase.stream().map(toUppercase).collect(Collectors.toSet());
  Assert.assertEquals(Set.of("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),uppercase);
}
Program: 37701
Project: 37701
Buggy source:
@Test public void biConsumer(){
  var result=new HashMap<String,String>();
  var biConsumer=new BiConsumer<String,String>(){
    @Override public void accept(    String key,    String value){
      result.put(key.toUpperCase(),value.toUpperCase());
    }
  }
;
  biConsumer.accept("String_Node_Str","String_Node_Str");
  Assert.assertEquals(this.createSmallMap(new String[]{"String_Node_Str","String_Node_Str"}),result);
  this.createSmallMap(new String[]{"String_Node_Str","String_Node_Str"},new String[]{"String_Node_Str","String_Node_Str"},new String[]{"String_Node_Str","String_Node_Str"}).forEach(biConsumer);
  Assert.assertEquals(this.createSmallMap(new String[]{"String_Node_Str","String_Node_Str"},new String[]{"String_Node_Str","String_Node_Str"},new String[]{"String_Node_Str","String_Node_Str"}),result);
}

Fixed version (ground truth):
@Test public void biConsumer(){
  var result=new HashMap<String,String>();
  var biConsumer=new BiConsumer<String,String>(){
    @Override public void accept(    String key,    String value){
      result.put(key.toUpperCase(),value.toUpperCase());
    }
  }
;
  biConsumer.accept("String_Node_Str","String_Node_Str");
  Assert.assertEquals(Map.of("String_Node_Str","String_Node_Str"),result);
  var lowercaseMap=Map.of("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  lowercaseMap.forEach(biConsumer);
  Assert.assertEquals(Map.of("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),result);
}
Program: 37702
Project: 37702
Buggy source:
@Test public void consumer(){
  var strings=List.of("String_Node_Str","String_Node_Str","String_Node_Str");
  var result=new ArrayList<String>();
  var consumer=new Consumer<String>(){
    @Override public void accept(    String each){
      result.add(each.toUpperCase());
    }
  }
;
  consumer.accept("String_Node_Str");
  Assert.assertEquals(List.of("String_Node_Str"),result);
  strings.forEach(consumer);
  Assert.assertEquals(List.of("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),result);
}

Fixed version (ground truth):
@Test public void consumer(){
  var strings=List.of("String_Node_Str","String_Node_Str","String_Node_Str");
  final var result=new ArrayList<String>();
  var consumer=new Consumer<String>(){
    @Override public void accept(    String each){
      result.add(each.toUpperCase());
    }
  }
;
  consumer.accept("String_Node_Str");
  Assert.assertEquals(List.of("String_Node_Str"),result);
  strings.forEach(consumer);
  Assert.assertEquals(List.of("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"),result);
}
Program: 37703
Project: 37703
Buggy source:
/** 
 * 模拟消息处理。如果当消息内容为FAIL_MESSAGE的话，则需要抛出异常
 * @param message
 * @throws Exception
 */
public void processMessage(Message message) throws Exception {
  String realMessage=new String(message.getBody());
  System.out.println("String_Node_Str" + realMessage + "String_Node_Str");
  if (Objects.equals(realMessage,FAIL_MESSAGE)) {
    throw new Exception("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * 模拟消息处理。如果当消息内容为FAIL_MESSAGE的话，则需要抛出异常
 * @param message
 * @throws Exception
 */
public void processMessage(Message message) throws Exception {
  String realMessage=new String(message.getBody());
  logger.info("String_Node_Str" + realMessage + "String_Node_Str");
  if (Objects.equals(realMessage,FAIL_MESSAGE)) {
    throw new Exception("String_Node_Str");
  }
}
Program: 37704
Project: 37704
Buggy source:
@Test public void testFailMessage() throws InterruptedException {
  ProcessReceiver.latch=new CountDownLatch(6);
  for (int i=1; i <= 3; i++) {
    rabbitTemplate.convertAndSend(QueueConfig.DELAY_QUEUE_PER_QUEUE_TTL_NAME,ProcessReceiver.FAIL_MESSAGE);
  }
  ProcessReceiver.latch.await();
}

Fixed version (ground truth):
@Test public void testFailMessage() throws InterruptedException {
  ProcessReceiver.latch=new CountDownLatch(6);
  for (int i=1; i <= 3; i++) {
    rabbitTemplate.convertAndSend(QueueConfig.DELAY_PROCESS_QUEUE_NAME,ProcessReceiver.FAIL_MESSAGE);
  }
  ProcessReceiver.latch.await();
}
Program: 37705
Project: 37705
Buggy source:
private List<Flow> loadFlows(String whereClause){
  String q="String_Node_Str" + whereClause + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  logger.debug("String_Node_Str",q);
  try (Session session=driver.session(AccessMode.READ)){
    StatementResult queryResults=session.run(q);
    List<Flow> results=new ArrayList<>();
    for (    Record record : queryResults.list()) {
      FlowAdapter adapter=new FlowAdapter(record);
      results.add(adapter.getFlow());
    }
    return results;
  }
 }

Fixed version (ground truth):
private List<Flow> loadFlows(String whereClause,Value parameters){
  String q="String_Node_Str" + whereClause + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  logger.debug("String_Node_Str",q);
  try (Session session=driver.session(AccessMode.READ)){
    StatementResult queryResults=session.run(q,parameters);
    List<Flow> results=new ArrayList<>();
    for (    Record record : queryResults.list()) {
      FlowAdapter adapter=new FlowAdapter(record);
      results.add(adapter.getFlow());
    }
    return results;
  }
 }
Program: 37706
Project: 37706
Buggy source:
@Override public List<Flow> getFlows(String flowId){
  String where="String_Node_Str" + flowId + "String_Node_Str";
  return loadFlows(where);
}

Fixed version (ground truth):
@Override public List<Flow> getFlows(String flowId){
  String where="String_Node_Str";
  Value parameters=Values.parameters("String_Node_Str",flowId);
  return loadFlows(where,parameters);
}
Program: 37707
Project: 37707
Buggy source:
@Override public List<Flow> getAllFlows(){
  String noWhere="String_Node_Str";
  return loadFlows(noWhere);
}

Fixed version (ground truth):
@Override public List<Flow> getAllFlows(){
  String noWhere="String_Node_Str";
  return loadFlows(noWhere,null);
}
Program: 37708
Project: 37708
Buggy source:
@Given("String_Node_Str") public void selectARandomSwitch(String switchAlias){
  List<Switch> switches=getUnaliasedSwitches();
  Random r=new Random();
  Switch theSwitch=switches.get(r.nextInt(switches.size()));
  log.info("String_Node_Str",theSwitch.getDpId());
  topologyUnderTest.addAlias(switchAlias,theSwitch);
}

Fixed version (ground truth):
@Given("String_Node_Str") public void selectARandomSwitch(String switchAlias){
  List<Switch> switches=getUnaliasedSwitches();
  Assume.assumeFalse("String_Node_Str",CollectionUtils.isEmpty(switches));
  Switch theSwitch=switches.get(0);
  log.info("String_Node_Str",theSwitch.getDpId());
  topologyUnderTest.addAlias(switchAlias,theSwitch);
}
Program: 37709
Project: 37709
Buggy source:
/** 
 * Checks if discovery should be suspended for that link.
 * @return true if link should be excluded from discovery plan and discovery packets should not be sent.
 */
public boolean isNewAttemptAllowed(){
  if (consecutiveFailureLimit == ENDLESS_ATTEMPTS) {
    return true;
  }
  return consecutiveFailure < consecutiveFailureLimit;
}

Fixed version (ground truth):
/** 
 * Checks if discovery should be suspended for that link or we can try to discover it.
 * @return true if link should be excluded from discovery plan and discovery packets should not be sent.
 */
public boolean isNewAttemptAllowed(){
  if (consecutiveFailureLimit == ENDLESS_ATTEMPTS) {
    return true;
  }
  return consecutiveFailure < consecutiveFailureLimit;
}