nus-yam/ex-repair huggingface dataset:
Program: 7351
Project: 7351
Buggy source:
@Nullable private MetricsRecord getMetricsRecord(MetricValue metricValue,Rule rule){
  String runId=metricValue.getTags().get(Constants.Metrics.Tag.RUN_ID);
  runId=runId == null ? "String_Node_Str" : runId;
  MetricsRecordBuilder builder=new MetricsRecordBuilder(runId,metricValue.getName(),metricValue.getTimestamp(),metricValue.getValue(),metricValue.getType());
  String namespace=metricValue.getTags().get(Constants.Metrics.Tag.NAMESPACE);
  namespace=namespace == null ? Constants.SYSTEM_NAMESPACE : namespace;
  int index=0;
  addToContext(builder,Constants.Metrics.Tag.NAMESPACE,namespace,index);
  for (  String tagName : rule.tagsToPutIntoContext) {
    String tagValue=metricValue.getTags().get(tagName);
    if (tagValue != null) {
      addToContext(builder,tagName,tagValue,index);
    }
 else {
      return null;
    }
  }
  for (  String tagName : rule.tagsToPutIntoTags) {
    String tagValue=metricValue.getTags().get(tagName);
    if (tagValue != null) {
      builder.addTag(tagValue);
    }
  }
  String scope=metricValue.getTags().get(Constants.Metrics.Tag.SCOPE);
  builder.prefixMetricName(scope == null ? "String_Node_Str" : scope + "String_Node_Str");
  return builder.build();
}

Fixed version (ground truth):
@Nullable private MetricsRecord getMetricsRecord(MetricValue metricValue,Rule rule){
  String runId=metricValue.getTags().get(Constants.Metrics.Tag.RUN_ID);
  runId=runId == null ? "String_Node_Str" : runId;
  MetricsRecordBuilder builder=new MetricsRecordBuilder(runId,metricValue.getName(),metricValue.getTimestamp(),metricValue.getValue(),metricValue.getType());
  String namespace=metricValue.getTags().get(Constants.Metrics.Tag.NAMESPACE);
  namespace=namespace == null ? Constants.SYSTEM_NAMESPACE : namespace;
  int index=0;
  addToContext(builder,Constants.Metrics.Tag.NAMESPACE,namespace,index++);
  for (  String tagName : rule.tagsToPutIntoContext) {
    String tagValue=metricValue.getTags().get(tagName);
    if (tagValue != null) {
      addToContext(builder,tagName,tagValue,index++);
    }
 else {
      return null;
    }
  }
  String instanceId=metricValue.getTags().get(Constants.Metrics.Tag.INSTANCE_ID);
  if (instanceId != null) {
    addToContext(builder,Constants.Metrics.Tag.INSTANCE_ID,instanceId,index++);
  }
  for (  String tagName : rule.tagsToPutIntoTags) {
    String tagValue=metricValue.getTags().get(tagName);
    if (tagValue != null) {
      builder.addTag(tagValue);
    }
  }
  String scope=metricValue.getTags().get(Constants.Metrics.Tag.SCOPE);
  builder.prefixMetricName(scope == null ? "String_Node_Str" : scope + "String_Node_Str");
  return builder.build();
}
Program: 7352
Project: 7352
Buggy source:
private void addToContext(MetricsRecordBuilder builder,String tagName,String tagValue,int index){
  if (Constants.Metrics.Tag.DATASET.equals(tagName) && index == 0) {
    builder.appendContext("String_Node_Str");
  }
 else   if (Constants.Metrics.Tag.CLUSTER_METRICS.equals(tagName) && index == 0) {
    builder.appendContext("String_Node_Str");
  }
 else {
    builder.appendContext(tagValue);
  }
}

Fixed version (ground truth):
private void addToContext(MetricsRecordBuilder builder,String tagName,String tagValue,int index){
  if (Constants.Metrics.Tag.DATASET.equals(tagName) && index == 1) {
    builder.appendContext("String_Node_Str");
  }
 else   if (Constants.Metrics.Tag.CLUSTER_METRICS.equals(tagName) && index == 1) {
    builder.appendContext("String_Node_Str");
  }
 else {
    builder.appendContext(tagValue);
  }
}
Program: 7353
Project: 7353
Buggy source:
@Test @Ignore public void testConcurrentIncrement() throws Exception {
  final MetricsTable table=getTable("String_Node_Str");
  final int rounds=500;
  Map<byte[],Long> inc1=ImmutableMap.of(X,1L,Y,2L);
  Map<byte[],Long> inc2=ImmutableMap.of(Y,1L,Z,2L);
  Collection<Thread> threads=ImmutableList.of(new IncThread(table,A,inc1,rounds),new IncThread(table,A,inc2,rounds),new IncAndGetThread(table,A,Z,5,rounds),new IncAndGetThread(table,A,Z,2,rounds));
  for (  Thread t : threads) {
    t.start();
  }
  for (  Thread t : threads) {
    t.join();
  }
  Assert.assertEquals(rounds + 10L,table.incrementAndGet(A,X,10L));
  Assert.assertEquals(3 * rounds - 20L,table.incrementAndGet(A,Y,-20L));
  Assert.assertEquals(9 * rounds,table.incrementAndGet(A,Z,0L));
}

Fixed version (ground truth):
@Test public void testConcurrentIncrement() throws Exception {
  final MetricsTable table=getTable("String_Node_Str");
  final int rounds=500;
  Map<byte[],Long> inc1=ImmutableMap.of(X,1L,Y,2L);
  Map<byte[],Long> inc2=ImmutableMap.of(Y,1L,Z,2L);
  Collection<? extends Thread> threads=ImmutableList.of(new IncThread(table,A,inc1,rounds),new IncThread(table,A,inc2,rounds),new IncAndGetThread(table,A,Z,5,rounds),new IncAndGetThread(table,A,Z,2,rounds));
  for (  Thread t : threads) {
    t.start();
  }
  for (  Thread t : threads) {
    t.join();
    if (t instanceof Closeable) {
      ((Closeable)t).close();
    }
  }
  Assert.assertEquals(rounds + 10L,table.incrementAndGet(A,X,10L));
  Assert.assertEquals(3 * rounds - 20L,table.incrementAndGet(A,Y,-20L));
  Assert.assertEquals(9 * rounds,table.incrementAndGet(A,Z,0L));
}
Program: 7354
Project: 7354
Buggy source:
IncAndGetThread(MetricsTable table,byte[] row,byte[] col,long delta,int rounds){
  this.table=table;
  this.row=row;
  this.col=col;
  this.delta=delta;
  this.rounds=rounds;
}

Fixed version (ground truth):
public IncAndGetThread(MetricsTable table,byte[] row,byte[] col,long delta,int rounds){
  this.table=table;
  this.row=row;
  this.col=col;
  this.delta=delta;
  this.rounds=rounds;
}
Program: 7355
Project: 7355
Buggy source:
IncThread(MetricsTable table,byte[] row,Map<byte[],Long> incrememts,int rounds){
  this.table=table;
  this.row=row;
  this.incrememts=incrememts;
  this.rounds=rounds;
}

Fixed version (ground truth):
public IncThread(MetricsTable table,byte[] row,Map<byte[],Long> incrememts,int rounds){
  this.table=table;
  this.row=row;
  this.incrememts=incrememts;
  this.rounds=rounds;
}
Program: 7356
Project: 7356
Buggy source:
@Nullable @Override public ResourceRequirement apply(@Nullable ResourceRequirement existingRequirement){
  Set<ResourceRequirement.Partition> partitions;
  if (existingRequirement != null) {
    partitions=existingRequirement.getPartitions();
  }
 else {
    partitions=ImmutableSet.of();
  }
  ResourceRequirement.Partition newPartition=new ResourceRequirement.Partition(streamName,1);
  if (partitions.contains(newPartition)) {
    return null;
  }
  ResourceRequirement.Builder builder=ResourceRequirement.builder(Constants.Service.STREAMS);
  builder.addPartition(newPartition);
  for (  ResourceRequirement.Partition partition : partitions) {
    builder.addPartition(partition);
  }
  return builder.build();
}

Fixed version (ground truth):
@Nullable @Override public ResourceRequirement apply(@Nullable ResourceRequirement existingRequirement){
  LOG.debug("String_Node_Str",streamName);
  Set<ResourceRequirement.Partition> partitions;
  if (existingRequirement != null) {
    partitions=existingRequirement.getPartitions();
  }
 else {
    partitions=ImmutableSet.of();
  }
  ResourceRequirement.Partition newPartition=new ResourceRequirement.Partition(streamName,1);
  if (partitions.contains(newPartition)) {
    return null;
  }
  ResourceRequirement.Builder builder=ResourceRequirement.builder(Constants.Service.STREAMS);
  builder.addPartition(newPartition);
  for (  ResourceRequirement.Partition partition : partitions) {
    builder.addPartition(partition);
  }
  return builder.build();
}
Program: 7357
Project: 7357
Buggy source:
@Override public ListenableFuture<Void> streamCreated(final String streamName){
  ListenableFuture<ResourceRequirement> future=resourceCoordinatorClient.modifyRequirement(Constants.Service.STREAMS,new ResourceModifier(){
    @Nullable @Override public ResourceRequirement apply(    @Nullable ResourceRequirement existingRequirement){
      Set<ResourceRequirement.Partition> partitions;
      if (existingRequirement != null) {
        partitions=existingRequirement.getPartitions();
      }
 else {
        partitions=ImmutableSet.of();
      }
      ResourceRequirement.Partition newPartition=new ResourceRequirement.Partition(streamName,1);
      if (partitions.contains(newPartition)) {
        return null;
      }
      ResourceRequirement.Builder builder=ResourceRequirement.builder(Constants.Service.STREAMS);
      builder.addPartition(newPartition);
      for (      ResourceRequirement.Partition partition : partitions) {
        builder.addPartition(partition);
      }
      return builder.build();
    }
  }
);
  return Futures.transform(future,Functions.<Void>constant(null));
}

Fixed version (ground truth):
@Override public ListenableFuture<Void> streamCreated(final String streamName){
  ListenableFuture<ResourceRequirement> future=resourceCoordinatorClient.modifyRequirement(Constants.Service.STREAMS,new ResourceModifier(){
    @Nullable @Override public ResourceRequirement apply(    @Nullable ResourceRequirement existingRequirement){
      LOG.debug("String_Node_Str",streamName);
      Set<ResourceRequirement.Partition> partitions;
      if (existingRequirement != null) {
        partitions=existingRequirement.getPartitions();
      }
 else {
        partitions=ImmutableSet.of();
      }
      ResourceRequirement.Partition newPartition=new ResourceRequirement.Partition(streamName,1);
      if (partitions.contains(newPartition)) {
        return null;
      }
      ResourceRequirement.Builder builder=ResourceRequirement.builder(Constants.Service.STREAMS);
      builder.addPartition(newPartition);
      for (      ResourceRequirement.Partition partition : partitions) {
        builder.addPartition(partition);
      }
      return builder.build();
    }
  }
);
  return Futures.transform(future,Functions.<Void>constant(null));
}
Program: 7358
Project: 7358
Buggy source:
@Override public synchronized void received(String streamName,long dataSize){
  AtomicLong value=streamSizes.get(streamName);
  if (value == null) {
    value=streamSizes.putIfAbsent(streamName,new AtomicLong(dataSize));
    if (value == null) {
      truncationSubscriptions.add(streamCoordinatorClient.addListener(streamName,new StreamPropertyListener(){
        @Override public void generationChanged(        String streamName,        int generation){
          streamSizes.put(streamName,new AtomicLong(0));
        }
      }
));
    }
  }
  if (value != null) {
    value.addAndGet(dataSize);
  }
}

Fixed version (ground truth):
@Override public synchronized void received(String streamName,long dataSize){
  AtomicLong value=streamSizes.get(streamName);
  if (value == null) {
    value=streamSizes.putIfAbsent(streamName,new AtomicLong(dataSize));
    if (value == null) {
      truncationSubscriptions.add(streamCoordinatorClient.addListener(streamName,new StreamPropertyListener(){
        @Override public void generationChanged(        String streamName,        int generation){
          streamSizes.put(streamName,new AtomicLong(0));
        }
      }
));
    }
  }
  if (value != null) {
    value.addAndGet(dataSize);
  }
  LOG.trace("String_Node_Str",streamName,dataSize,value.get());
}
Program: 7359
Project: 7359
Buggy source:
/** 
 * Elect one leader among the   {@link DistributedStreamService}s running in different Twill runnables.
 */
private void performLeaderElection(){
  leaderElection=new LeaderElection(zkClient,"String_Node_Str" + STREAMS_COORDINATOR,new ElectionHandler(){
    @Override public void leader(){
      LOG.info("String_Node_Str");
      resourceCoordinator=new ResourceCoordinator(zkClient,discoveryServiceClient,new BalancedAssignmentStrategy());
      resourceCoordinator.startAndWait();
      resourceCoordinatorClient.modifyRequirement(Constants.Service.STREAMS,new ResourceModifier(){
        @Nullable @Override public ResourceRequirement apply(        @Nullable ResourceRequirement existingRequirement){
          try {
            ResourceRequirement.Builder builder=ResourceRequirement.builder(Constants.Service.STREAMS);
            for (            StreamSpecification spec : streamMetaStore.listStreams()) {
              LOG.debug("String_Node_Str",spec.getName());
              builder.addPartition(new ResourceRequirement.Partition(spec.getName(),1));
            }
            return builder.build();
          }
 catch (          Throwable e) {
            LOG.error("String_Node_Str",e);
            Throwables.propagate(e);
            return null;
          }
        }
      }
);
    }
    @Override public void follower(){
      LOG.info("String_Node_Str");
      if (resourceCoordinator != null) {
        resourceCoordinator.stopAndWait();
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Elect one leader among the   {@link DistributedStreamService}s running in different Twill runnables.
 */
private void performLeaderElection(){
  leaderElection=new LeaderElection(zkClient,"String_Node_Str" + STREAMS_COORDINATOR,new ElectionHandler(){
    @Override public void leader(){
      LOG.info("String_Node_Str");
      resourceCoordinator=new ResourceCoordinator(zkClient,discoveryServiceClient,new BalancedAssignmentStrategy());
      resourceCoordinator.startAndWait();
      resourceCoordinatorClient.modifyRequirement(Constants.Service.STREAMS,new ResourceModifier(){
        @Nullable @Override public ResourceRequirement apply(        @Nullable ResourceRequirement existingRequirement){
          try {
            ResourceRequirement.Builder builder=ResourceRequirement.builder(Constants.Service.STREAMS);
            for (            StreamSpecification spec : streamMetaStore.listStreams()) {
              LOG.debug("String_Node_Str",spec.getName());
              builder.addPartition(new ResourceRequirement.Partition(spec.getName(),1));
            }
            return builder.build();
          }
 catch (          Throwable e) {
            LOG.error("String_Node_Str",e);
            Throwables.propagate(e);
            return null;
          }
        }
      }
);
    }
    @Override public void follower(){
      LOG.info("String_Node_Str");
      if (resourceCoordinator != null) {
        resourceCoordinator.stopAndWait();
      }
    }
  }
);
  leaderElection.start();
}
Program: 7360
Project: 7360
Buggy source:
protected StreamSizeAggregator(String streamName,long baseCount,int streamThresholdMB,Cancellable cancellable){
  this.streamWriterSizes=Maps.newHashMap();
  this.streamBaseCount=new AtomicLong(baseCount);
  this.streamThresholdMB=new AtomicInteger(streamThresholdMB);
  this.cancellable=cancellable;
  this.streamFeed=new NotificationFeed.Builder().setNamespace(Constants.DEFAULT_NAMESPACE).setCategory(Constants.Notification.Stream.STREAM_FEED_CATEGORY).setName(streamName).build();
}

Fixed version (ground truth):
protected StreamSizeAggregator(String streamName,long baseCount,int streamThresholdMB,Cancellable cancellable){
  this.streamWriterSizes=Maps.newHashMap();
  this.streamBaseCount=new AtomicLong(baseCount);
  this.countFromFiles=new AtomicLong(baseCount);
  this.streamThresholdMB=new AtomicInteger(streamThresholdMB);
  this.cancellable=cancellable;
  this.isInit=true;
  this.streamFeed=new NotificationFeed.Builder().setNamespace(Constants.DEFAULT_NAMESPACE).setCategory(Constants.Notification.Stream.STREAM_FEED_CATEGORY).setName(streamName).build();
}
Program: 7361
Project: 7361
Buggy source:
/** 
 * Perform aggregation on the Streams described by the   {@code streamNames}, and no other Streams. If aggregation was previously done on other Streams, those must be cancelled.
 * @param streamNames names of the streams to perform data sizes aggregation on
 */
private void aggregate(Set<String> streamNames){
  Set<String> existingAggregators=Sets.newHashSet(aggregators.keySet());
  for (  String streamName : streamNames) {
    if (existingAggregators.remove(streamName)) {
      continue;
    }
    try {
      StreamConfig config=streamAdmin.getConfig(streamName);
      long filesSize=StreamUtils.fetchStreamFilesSize(config);
      createSizeAggregator(streamName,filesSize,config.getNotificationThresholdMB());
    }
 catch (    IOException e) {
      LOG.error("String_Node_Str",streamName);
      Throwables.propagate(e);
    }
  }
  for (  String outdatedStream : existingAggregators) {
    StreamSizeAggregator aggregator=aggregators.remove(outdatedStream);
    if (aggregator != null) {
      aggregator.cancel();
    }
  }
}

Fixed version (ground truth):
/** 
 * Perform aggregation on the Streams described by the   {@code streamNames}, and no other Streams. If aggregation was previously done on other Streams, those must be cancelled.
 * @param streamNames names of the streams to perform data sizes aggregation on
 */
private void aggregate(Set<String> streamNames){
  Set<String> existingAggregators=Sets.newHashSet(aggregators.keySet());
  for (  String streamName : streamNames) {
    if (existingAggregators.remove(streamName)) {
      continue;
    }
    try {
      StreamConfig config=streamAdmin.getConfig(streamName);
      long filesSize=StreamUtils.fetchStreamFilesSize(config);
      LOG.debug("String_Node_Str",streamName,filesSize);
      createSizeAggregator(streamName,filesSize,config.getNotificationThresholdMB());
    }
 catch (    IOException e) {
      LOG.error("String_Node_Str",streamName);
      Throwables.propagate(e);
    }
  }
  for (  String outdatedStream : existingAggregators) {
    StreamSizeAggregator aggregator=aggregators.remove(outdatedStream);
    if (aggregator != null) {
      aggregator.cancel();
    }
  }
}
Program: 7363
Project: 7363
Buggy source:
/** 
 * Call all the listeners that are interested in knowing that this coordinator is the leader of a set of Streams.
 * @param streamNames set of Streams that this coordinator is the leader of
 */
private void invokeLeaderListeners(Set<String> streamNames){
  Set<StreamLeaderListener> listeners;
synchronized (this) {
    listeners=ImmutableSet.copyOf(leaderListeners);
  }
  for (  StreamLeaderListener listener : listeners) {
    listener.leaderOf(streamNames);
  }
}

Fixed version (ground truth):
/** 
 * Call all the listeners that are interested in knowing that this Stream writer is the leader of a set of Streams.
 * @param streamNames set of Streams that this coordinator is the leader of
 */
private void invokeLeaderListeners(Set<String> streamNames){
  LOG.debug("String_Node_Str",streamNames);
  Set<StreamLeaderListener> listeners;
synchronized (this) {
    listeners=ImmutableSet.copyOf(leaderListeners);
  }
  for (  StreamLeaderListener listener : listeners) {
    listener.leaderOf(streamNames);
  }
}
Program: 7364
Project: 7364
Buggy source:
/** 
 * Check if the current size of data is enough to trigger a notification.
 */
private void checkSendNotification(){
  long sum=0;
  for (  Long size : streamWriterSizes.values()) {
    sum+=size;
  }
  if (isInit || sum - streamBaseCount.get() > streamThresholdMB.get()) {
    try {
      publishNotification(sum);
    }
  finally {
      streamBaseCount.set(sum);
    }
  }
}

Fixed version (ground truth):
/** 
 * Check if the current size of data is enough to trigger a notification.
 */
private void checkSendNotification(){
  long sum=countFromFiles.get();
  for (  Long size : streamWriterSizes.values()) {
    sum+=size;
  }
  if (isInit || sum - streamBaseCount.get() > streamThresholdMB.get()) {
    try {
      publishNotification(sum);
    }
  finally {
      streamBaseCount.set(sum);
      countFromFiles.set(0);
    }
  }
  isInit=false;
}
Program: 7365
Project: 7365
Buggy source:
@Override protected void runOneIteration() throws Exception {
  LOG.trace("String_Node_Str",instanceId);
  ImmutableMap.Builder<String,Long> sizes=ImmutableMap.builder();
  for (  StreamSpecification streamSpec : streamMetaStore.listStreams()) {
    sizes.put(streamSpec.getName(),streamWriterSizeCollector.getTotalCollected(streamSpec.getName()));
  }
  heartbeatPublisher.sendHeartbeat(new StreamWriterHeartbeat(System.currentTimeMillis(),instanceId,sizes.build()));
}

Fixed version (ground truth):
@Override protected void runOneIteration() throws Exception {
  LOG.trace("String_Node_Str",instanceId);
  ImmutableMap.Builder<String,Long> sizes=ImmutableMap.builder();
  for (  StreamSpecification streamSpec : streamMetaStore.listStreams()) {
    sizes.put(streamSpec.getName(),streamWriterSizeCollector.getTotalCollected(streamSpec.getName()));
  }
  StreamWriterHeartbeat heartbeat=new StreamWriterHeartbeat(System.currentTimeMillis(),instanceId,sizes.build());
  LOG.trace("String_Node_Str",heartbeat);
  heartbeatPublisher.sendHeartbeat(heartbeat);
}
Program: 7366
Project: 7366
Buggy source:
/** 
 * Subscribe to the streams heartbeat notification feed. One heartbeat contains data for all existing streams, we filter that to only take into account the streams that this   {@link DistributedStreamService} is a leaderof.
 * @return a {@link Cancellable} to cancel the subscription
 * @throws NotificationException if the heartbeat feed does not exist
 */
private Cancellable subscribeToHeartbeatsFeed() throws NotificationException {
  final NotificationFeed heartbeatsFeed=new NotificationFeed.Builder().setNamespace(Constants.DEFAULT_NAMESPACE).setCategory(Constants.Notification.Stream.STREAM_INTERNAL_FEED_CATEGORY).setName(Constants.Notification.Stream.STREAM_HEARTBEAT_FEED_NAME).build();
  return notificationService.subscribe(heartbeatsFeed,new NotificationHandler<StreamWriterHeartbeat>(){
    @Override public Type getNotificationFeedType(){
      return StreamWriterHeartbeat.class;
    }
    @Override public void received(    StreamWriterHeartbeat heartbeat,    NotificationContext notificationContext){
      for (      Map.Entry<String,Long> entry : heartbeat.getStreamsSizes().entrySet()) {
        StreamSizeAggregator streamSizeAggregator=aggregators.get(entry.getKey());
        if (streamSizeAggregator == null) {
          continue;
        }
        streamSizeAggregator.bytesReceived(heartbeat.getInstanceId(),entry.getValue());
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Subscribe to the streams heartbeat notification feed. One heartbeat contains data for all existing streams, we filter that to only take into account the streams that this   {@link DistributedStreamService} is a leaderof.
 * @return a {@link Cancellable} to cancel the subscription
 * @throws NotificationException if the heartbeat feed does not exist
 */
private Cancellable subscribeToHeartbeatsFeed() throws NotificationException {
  final NotificationFeed heartbeatsFeed=new NotificationFeed.Builder().setNamespace(Constants.DEFAULT_NAMESPACE).setCategory(Constants.Notification.Stream.STREAM_INTERNAL_FEED_CATEGORY).setName(Constants.Notification.Stream.STREAM_HEARTBEAT_FEED_NAME).build();
  LOG.trace("String_Node_Str");
  return notificationService.subscribe(heartbeatsFeed,new NotificationHandler<StreamWriterHeartbeat>(){
    @Override public Type getNotificationFeedType(){
      return StreamWriterHeartbeat.class;
    }
    @Override public void received(    StreamWriterHeartbeat heartbeat,    NotificationContext notificationContext){
      LOG.trace("String_Node_Str",heartbeat);
      for (      Map.Entry<String,Long> entry : heartbeat.getStreamsSizes().entrySet()) {
        StreamSizeAggregator streamSizeAggregator=aggregators.get(entry.getKey());
        if (streamSizeAggregator == null) {
          LOG.trace("String_Node_Str",entry.getKey());
          continue;
        }
        streamSizeAggregator.bytesReceived(heartbeat.getInstanceId(),entry.getValue());
      }
    }
  }
);
}
Program: 7367
Project: 7367
Buggy source:
@Override public void onChange(Collection<PartitionReplica> partitionReplicas){
  Set<String> streamNames=ImmutableSet.copyOf(Iterables.transform(partitionReplicas,new Function<PartitionReplica,String>(){
    @Nullable @Override public String apply(    @Nullable PartitionReplica input){
      return input != null ? input.getName() : null;
    }
  }
));
  invokeLeaderListeners(ImmutableSet.copyOf(streamNames));
}

Fixed version (ground truth):
@Override public void onChange(Collection<PartitionReplica> partitionReplicas){
  LOG.debug("String_Node_Str");
  Set<String> streamNames=ImmutableSet.copyOf(Iterables.transform(partitionReplicas,new Function<PartitionReplica,String>(){
    @Nullable @Override public String apply(    @Nullable PartitionReplica input){
      return input != null ? input.getName() : null;
    }
  }
));
  invokeLeaderListeners(ImmutableSet.copyOf(streamNames));
}
Program: 7368
Project: 7368
Buggy source:
@Inject public DistributedStreamService(CConfiguration cConf,StreamAdmin streamAdmin,StreamCoordinatorClient streamCoordinatorClient,StreamFileJanitorService janitorService,ZKClient zkClient,DiscoveryServiceClient discoveryServiceClient,StreamMetaStore streamMetaStore,Supplier<Discoverable> discoverableSupplier,StreamWriterSizeCollector streamWriterSizeCollector,HeartbeatPublisher heartbeatPublisher,NotificationFeedManager feedManager,NotificationService notificationService){
  super(streamCoordinatorClient,janitorService,streamWriterSizeCollector);
  this.zkClient=zkClient;
  this.streamAdmin=streamAdmin;
  this.notificationService=notificationService;
  this.discoveryServiceClient=discoveryServiceClient;
  this.streamMetaStore=streamMetaStore;
  this.discoverableSupplier=discoverableSupplier;
  this.feedManager=feedManager;
  this.streamWriterSizeCollector=streamWriterSizeCollector;
  this.heartbeatPublisher=heartbeatPublisher;
  this.resourceCoordinatorClient=new ResourceCoordinatorClient(zkClient);
  this.leaderListeners=Sets.newHashSet();
  this.instanceId=cConf.getInt(Constants.Stream.CONTAINER_INSTANCE_ID);
  this.aggregators=Maps.newConcurrentMap();
  this.isInit=true;
}

Fixed version (ground truth):
@Inject public DistributedStreamService(CConfiguration cConf,StreamAdmin streamAdmin,StreamCoordinatorClient streamCoordinatorClient,StreamFileJanitorService janitorService,ZKClient zkClient,DiscoveryServiceClient discoveryServiceClient,StreamMetaStore streamMetaStore,Supplier<Discoverable> discoverableSupplier,StreamWriterSizeCollector streamWriterSizeCollector,HeartbeatPublisher heartbeatPublisher,NotificationFeedManager feedManager,NotificationService notificationService){
  super(streamCoordinatorClient,janitorService,streamWriterSizeCollector);
  this.zkClient=zkClient;
  this.streamAdmin=streamAdmin;
  this.notificationService=notificationService;
  this.discoveryServiceClient=discoveryServiceClient;
  this.streamMetaStore=streamMetaStore;
  this.discoverableSupplier=discoverableSupplier;
  this.feedManager=feedManager;
  this.streamWriterSizeCollector=streamWriterSizeCollector;
  this.heartbeatPublisher=heartbeatPublisher;
  this.resourceCoordinatorClient=new ResourceCoordinatorClient(zkClient);
  this.leaderListeners=Sets.newHashSet();
  this.instanceId=cConf.getInt(Constants.Stream.CONTAINER_INSTANCE_ID);
  this.aggregators=Maps.newConcurrentMap();
}
Program: 7369
Project: 7369
Buggy source:
@Override public void received(StreamWriterHeartbeat heartbeat,NotificationContext notificationContext){
  for (  Map.Entry<String,Long> entry : heartbeat.getStreamsSizes().entrySet()) {
    StreamSizeAggregator streamSizeAggregator=aggregators.get(entry.getKey());
    if (streamSizeAggregator == null) {
      continue;
    }
    streamSizeAggregator.bytesReceived(heartbeat.getInstanceId(),entry.getValue());
  }
}

Fixed version (ground truth):
@Override public void received(StreamWriterHeartbeat heartbeat,NotificationContext notificationContext){
  LOG.trace("String_Node_Str",heartbeat);
  for (  Map.Entry<String,Long> entry : heartbeat.getStreamsSizes().entrySet()) {
    StreamSizeAggregator streamSizeAggregator=aggregators.get(entry.getKey());
    if (streamSizeAggregator == null) {
      LOG.trace("String_Node_Str",entry.getKey());
      continue;
    }
    streamSizeAggregator.bytesReceived(heartbeat.getInstanceId(),entry.getValue());
  }
}
Program: 7370
Project: 7370
Buggy source:
/** 
 * Notify this aggregator that a certain number of bytes have been received from the stream writer with instance  {@code instanceId}.
 * @param instanceId id of the stream writer from which we received some bytes
 * @param nbBytes number of bytes of data received
 */
public void bytesReceived(int instanceId,long nbBytes){
  Long lastSize=streamWriterSizes.get(instanceId);
  if (lastSize == null) {
    streamWriterSizes.put(instanceId,nbBytes);
    return;
  }
  streamWriterSizes.put(instanceId,lastSize + nbBytes);
  checkSendNotification();
}

Fixed version (ground truth):
/** 
 * Notify this aggregator that a certain number of bytes have been received from the stream writer with instance  {@code instanceId}.
 * @param instanceId id of the stream writer from which we received some bytes
 * @param nbBytes number of bytes of data received
 */
public void bytesReceived(int instanceId,long nbBytes){
  LOG.trace("String_Node_Str",instanceId,nbBytes);
  streamWriterSizes.put(instanceId,nbBytes);
  checkSendNotification();
}
Program: 7371
Project: 7371
Buggy source:
@Override public void generationChanged(String streamName,int generation){
  Cancellable previousAggregator=aggregators.replace(streamName,createSizeAggregator(streamName,0,threshold));
  if (previousAggregator != null) {
    previousAggregator.cancel();
  }
}

Fixed version (ground truth):
@Override public void generationChanged(String streamName,int generation){
  int currentThresold=threshold;
  StreamSizeAggregator currentAggregator=aggregators.get(streamName);
  if (currentAggregator != null) {
    currentThresold=currentAggregator.getStreamThresholdMB();
  }
  Cancellable previousAggregator=aggregators.replace(streamName,createSizeAggregator(streamName,0,currentThresold));
  if (previousAggregator != null) {
    previousAggregator.cancel();
  }
}
Program: 7372
Project: 7372
Buggy source:
@Override public Module getDistributedModules(){
  return new AbstractModule(){
    @Override protected void configure(){
      bind(StreamFileJanitorService.class).to(DistributedStreamFileJanitorService.class).in(Scopes.SINGLETON);
      bind(StreamWriterSizeCollector.class).to(BasicStreamWriterSizeCollector.class).in(Scopes.SINGLETON);
      bind(StreamService.class).to(DistributedStreamService.class).in(Scopes.SINGLETON);
      Multibinder<HttpHandler> handlerBinder=Multibinder.newSetBinder(binder(),HttpHandler.class,Names.named(Constants.Stream.STREAM_HANDLER));
      handlerBinder.addBinding().to(StreamHandler.class);
      handlerBinder.addBinding().to(StreamFetchHandler.class);
      handlerBinder.addBinding().to(PingHandler.class);
      bind(HeartbeatPublisher.class).to(NoOpHeartbeatPublisher.class).in(Scopes.SINGLETON);
      bind(StreamHttpService.class).in(Scopes.SINGLETON);
      bind(Key.get(new TypeLiteral<Supplier<Discoverable>>(){
      }
)).to(StreamHttpService.class);
    }
  }
;
}

Fixed version (ground truth):
@Override public Module getDistributedModules(){
  return new AbstractModule(){
    @Override protected void configure(){
      bind(StreamFileJanitorService.class).to(DistributedStreamFileJanitorService.class).in(Scopes.SINGLETON);
      bind(StreamWriterSizeCollector.class).to(BasicStreamWriterSizeCollector.class).in(Scopes.SINGLETON);
      bind(StreamService.class).to(DistributedStreamService.class).in(Scopes.SINGLETON);
      Multibinder<HttpHandler> handlerBinder=Multibinder.newSetBinder(binder(),HttpHandler.class,Names.named(Constants.Stream.STREAM_HANDLER));
      handlerBinder.addBinding().to(StreamHandler.class);
      handlerBinder.addBinding().to(StreamFetchHandler.class);
      handlerBinder.addBinding().to(PingHandler.class);
      bind(HeartbeatPublisher.class).to(NotificationHeartbeatPublisher.class).in(Scopes.SINGLETON);
      bind(StreamHttpService.class).in(Scopes.SINGLETON);
      bind(Key.get(new TypeLiteral<Supplier<Discoverable>>(){
      }
)).to(StreamHttpService.class);
    }
  }
;
}
Program: 7373
Project: 7373
Buggy source:
@Override protected void configure(){
  bind(StreamFileJanitorService.class).to(DistributedStreamFileJanitorService.class).in(Scopes.SINGLETON);
  bind(StreamWriterSizeCollector.class).to(BasicStreamWriterSizeCollector.class).in(Scopes.SINGLETON);
  bind(StreamService.class).to(DistributedStreamService.class).in(Scopes.SINGLETON);
  Multibinder<HttpHandler> handlerBinder=Multibinder.newSetBinder(binder(),HttpHandler.class,Names.named(Constants.Stream.STREAM_HANDLER));
  handlerBinder.addBinding().to(StreamHandler.class);
  handlerBinder.addBinding().to(StreamFetchHandler.class);
  handlerBinder.addBinding().to(PingHandler.class);
  bind(HeartbeatPublisher.class).to(NoOpHeartbeatPublisher.class).in(Scopes.SINGLETON);
  bind(StreamHttpService.class).in(Scopes.SINGLETON);
  bind(Key.get(new TypeLiteral<Supplier<Discoverable>>(){
  }
)).to(StreamHttpService.class);
}

Fixed version (ground truth):
@Override protected void configure(){
  bind(StreamFileJanitorService.class).to(DistributedStreamFileJanitorService.class).in(Scopes.SINGLETON);
  bind(StreamWriterSizeCollector.class).to(BasicStreamWriterSizeCollector.class).in(Scopes.SINGLETON);
  bind(StreamService.class).to(DistributedStreamService.class).in(Scopes.SINGLETON);
  Multibinder<HttpHandler> handlerBinder=Multibinder.newSetBinder(binder(),HttpHandler.class,Names.named(Constants.Stream.STREAM_HANDLER));
  handlerBinder.addBinding().to(StreamHandler.class);
  handlerBinder.addBinding().to(StreamFetchHandler.class);
  handlerBinder.addBinding().to(PingHandler.class);
  bind(HeartbeatPublisher.class).to(NotificationHeartbeatPublisher.class).in(Scopes.SINGLETON);
  bind(StreamHttpService.class).in(Scopes.SINGLETON);
  bind(Key.get(new TypeLiteral<Supplier<Discoverable>>(){
  }
)).to(StreamHttpService.class);
}
Program: 7374
Project: 7374
Buggy source:
/** 
 * Publish one heartbeat.
 * @param heartbeat heartbeat to publish
 * @return a {@link ListenableFuture} describing the state of publishing. The {@link ListenableFuture#get} methodwill return the published heartbeat.
 */
ListenableFuture<StreamWriterHeartbeat> sendHeartbeat(StreamWriterHeartbeat heartbeat);

Fixed version (ground truth):
/** 
 * Publish one heartbeat.
 * @param heartbeat heartbeat to publish
 * @return a {@link ListenableFuture} describing the state of publishing. The {@link ListenableFuture#get} methodwill return the published heartbeat.
 * @throws IOException when the {@code heartbeat}
 */
ListenableFuture<StreamWriterHeartbeat> sendHeartbeat(StreamWriterHeartbeat heartbeat) throws IOException ;
Program: 7375
Project: 7375
Buggy source:
/** 
 * Called when a notification is received on a feed, to push it to all the handlers that subscribed to the feed.
 * @param feed {@link NotificationFeed} of the notification
 * @param notificationJson notification as a json object
 */
protected void notificationReceived(NotificationFeed feed,JsonElement notificationJson){
  Collection<NotificationCaller<?>> callers=subscribers.get(feed);
synchronized (subscribers) {
    callers=ImmutableList.copyOf(callers);
  }
  for (  NotificationCaller caller : callers) {
    Object notification=GSON.fromJson(notificationJson,caller.getNotificationFeedType());
    caller.received(notification,new BasicNotificationContext(dsFramework,transactionSystemClient));
  }
}

Fixed version (ground truth):
/** 
 * Called when a notification is received on a feed, to push it to all the handlers that subscribed to the feed.
 * @param feed {@link NotificationFeed} of the notification
 * @param notificationJson notification as a json object
 */
protected void notificationReceived(NotificationFeed feed,JsonElement notificationJson){
  LOG.trace("String_Node_Str",feed,notificationJson);
  Collection<NotificationCaller<?>> callers=subscribers.get(feed);
synchronized (subscribers) {
    callers=ImmutableList.copyOf(callers);
  }
  for (  NotificationCaller caller : callers) {
    Object notification=GSON.fromJson(notificationJson,caller.getNotificationFeedType());
    caller.received(notification,new BasicNotificationContext(dsFramework,transactionSystemClient));
  }
}
Program: 7376
Project: 7376
Buggy source:
private String nextToken(){
  char currChar=schema.charAt(pos);
  int endPos=pos;
  while (!(endPos == end || Character.isWhitespace(currChar) || currChar == ':' || currChar == ',' || currChar == '<' || currChar == '>')) {
    endPos++;
    currChar=schema.charAt(endPos);
  }
  String token=schema.substring(pos,endPos);
  pos=endPos;
  return token;
}

Fixed version (ground truth):
private String nextToken(){
  char currChar=schema.charAt(pos);
  int endPos=pos;
  while (!(Character.isWhitespace(currChar) || currChar == ':' || currChar == ',' || currChar == '<' || currChar == '>')) {
    endPos++;
    if (endPos == end) {
      break;
    }
    currChar=schema.charAt(endPos);
  }
  String token=schema.substring(pos,endPos);
  pos=endPos;
  return token;
}
Program: 7377
Project: 7377
Buggy source:
@Test public void testParseFlatSQL() throws IOException {
  String schemaStr="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";
  Schema expected=Schema.recordOf("String_Node_Str",Schema.Field.of("String_Node_Str",Schema.nullableOf(Schema.of(Schema.Type.BOOLEAN))),Schema.Field.of("String_Node_Str",Schema.of(Schema.Type.INT)),Schema.Field.of("String_Node_Str",Schema.of(Schema.Type.LONG)),Schema.Field.of("String_Node_Str",Schema.of(Schema.Type.FLOAT)),Schema.Field.of("String_Node_Str",Schema.of(Schema.Type.DOUBLE)),Schema.Field.of("String_Node_Str",Schema.of(Schema.Type.BYTES)),Schema.Field.of("String_Node_Str",Schema.of(Schema.Type.STRING)),Schema.Field.of("String_Node_Str",Schema.arrayOf(Schema.nullableOf(Schema.of(Schema.Type.STRING)))),Schema.Field.of("String_Node_Str",Schema.mapOf(Schema.nullableOf(Schema.of(Schema.Type.STRING)),Schema.nullableOf(Schema.of(Schema.Type.INT)))),Schema.Field.of("String_Node_Str",Schema.nullableOf(Schema.recordOf("String_Node_Str",Schema.Field.of("String_Node_Str",Schema.nullableOf(Schema.of(Schema.Type.INT))),Schema.Field.of("String_Node_Str",Schema.nullableOf(Schema.of(Schema.Type.DOUBLE)))))));
  Assert.assertEquals(expected,Schema.parseSQL(schemaStr));
}

Fixed version (ground truth):
@Test public void testParseFlatSQL() throws IOException {
  String schemaStr="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";
  Schema expected=Schema.recordOf("String_Node_Str",Schema.Field.of("String_Node_Str",Schema.nullableOf(Schema.of(Schema.Type.BOOLEAN))),Schema.Field.of("String_Node_Str",Schema.of(Schema.Type.INT)),Schema.Field.of("String_Node_Str",Schema.of(Schema.Type.LONG)),Schema.Field.of("String_Node_Str",Schema.of(Schema.Type.FLOAT)),Schema.Field.of("String_Node_Str",Schema.of(Schema.Type.DOUBLE)),Schema.Field.of("String_Node_Str",Schema.of(Schema.Type.BYTES)),Schema.Field.of("String_Node_Str",Schema.arrayOf(Schema.nullableOf(Schema.of(Schema.Type.STRING)))),Schema.Field.of("String_Node_Str",Schema.mapOf(Schema.nullableOf(Schema.of(Schema.Type.STRING)),Schema.nullableOf(Schema.of(Schema.Type.INT)))),Schema.Field.of("String_Node_Str",Schema.nullableOf(Schema.recordOf("String_Node_Str",Schema.Field.of("String_Node_Str",Schema.nullableOf(Schema.of(Schema.Type.INT))),Schema.Field.of("String_Node_Str",Schema.nullableOf(Schema.of(Schema.Type.DOUBLE)))))),Schema.Field.of("String_Node_Str",Schema.nullableOf(Schema.of(Schema.Type.STRING))));
  Assert.assertEquals(expected,Schema.parseSQL(schemaStr));
}
Program: 7379
Project: 7379
Buggy source:
@Inject public DistributedStreamService(StreamCoordinatorClient streamCoordinatorClient,StreamFileJanitorService janitorService,StreamWriterSizeManager sizeManager,ZKClient zkClient,DiscoveryServiceClient discoveryServiceClient,StreamMetaStore streamMetaStore,Supplier<Discoverable> discoverableSupplier){
  super(streamCoordinatorClient,janitorService,sizeManager);
  this.zkClient=zkClient;
  this.discoveryServiceClient=discoveryServiceClient;
  this.streamMetaStore=streamMetaStore;
  this.discoverableSupplier=discoverableSupplier;
  this.resourceCoordinatorClient=new ResourceCoordinatorClient(zkClient);
  this.leaderListeners=Sets.newHashSet();
}

Fixed version (ground truth):
@Inject public DistributedStreamService(StreamCoordinatorClient streamCoordinatorClient,StreamFileJanitorService janitorService,StreamWriterSizeManager sizeManager,ZKClient zkClient,DiscoveryServiceClient discoveryServiceClient,StreamMetaStore streamMetaStore,Supplier<Discoverable> discoverableSupplier,NotificationFeedManager notificationFeedManager){
  super(streamCoordinatorClient,janitorService,sizeManager,notificationFeedManager);
  this.zkClient=zkClient;
  this.discoveryServiceClient=discoveryServiceClient;
  this.streamMetaStore=streamMetaStore;
  this.discoverableSupplier=discoverableSupplier;
  this.resourceCoordinatorClient=new ResourceCoordinatorClient(zkClient);
  this.leaderListeners=Sets.newHashSet();
}
Program: 7380
Project: 7380
Buggy source:
@Inject public LocalStreamService(StreamCoordinatorClient streamCoordinatorClient,StreamFileJanitorService janitorService,StreamWriterSizeManager sizeManager){
  super(streamCoordinatorClient,janitorService,sizeManager);
}

Fixed version (ground truth):
@Inject public LocalStreamService(StreamCoordinatorClient streamCoordinatorClient,StreamFileJanitorService janitorService,StreamWriterSizeManager sizeManager,NotificationFeedManager notificationFeedManager){
  super(streamCoordinatorClient,janitorService,sizeManager,notificationFeedManager);
}
Program: 7381
Project: 7381
Buggy source:
@Override public void increment(String metricName,int value){
}

Fixed version (ground truth):
@Override public void increment(String metricName,long value){
}
Program: 7385
Project: 7385
Buggy source:
private void runUserCodeInTx(TransactionExecutor.Procedure<MapReduceContext> userCode){
  TransactionContext txContext=new TransactionContext(txClient,context.getDatasetInstantiator().getTransactionAware());
  DynamicBasicMapReduceContext mapReduceContextWithTX=null;
  try {
    txContext.start();
    mapReduceContextWithTX=new DynamicBasicMapReduceContext(context,datasetFramework,txContext,cConf);
    userCode.apply(mapReduceContextWithTX);
    txContext.finish();
  }
 catch (  TransactionFailureException e) {
    abortTransaction(e,"String_Node_Str",txContext);
  }
catch (  Throwable t) {
    abortTransaction(t,"String_Node_Str",txContext);
  }
 finally {
    if (mapReduceContextWithTX != null) {
      mapReduceContextWithTX.close();
    }
  }
}

Fixed version (ground truth):
private void runUserCodeInTx(TransactionExecutor.Procedure<MapReduceContext> userCode,String methodName){
  TransactionContext txContext=new TransactionContext(txClient,context.getDatasetInstantiator().getTransactionAware());
  DynamicBasicMapReduceContext mapReduceContextWithTX=null;
  try {
    txContext.start();
    mapReduceContextWithTX=new DynamicBasicMapReduceContext(context,datasetFramework,txContext,cConf);
    userCode.apply(mapReduceContextWithTX);
    txContext.finish();
  }
 catch (  TransactionFailureException e) {
    abortTransaction(e,"String_Node_Str" + methodName + "String_Node_Str",txContext);
  }
catch (  Throwable t) {
    abortTransaction(t,"String_Node_Str" + methodName + "String_Node_Str",txContext);
  }
 finally {
    if (mapReduceContextWithTX != null) {
      mapReduceContextWithTX.close();
    }
  }
}
Program: 7386
Project: 7386
Buggy source:
/** 
 * Calls the   {@link MapReduce#onFinish(boolean,co.cask.cdap.api.mapreduce.MapReduceContext)} method.
 */
private void onFinish(final boolean succeeded) throws TransactionFailureException, InterruptedException {
  runUserCodeInTx(new TransactionExecutor.Procedure<MapReduceContext>(){
    @Override public void apply(    MapReduceContext context) throws Exception {
      mapReduce.onFinish(succeeded,context);
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Calls the   {@link MapReduce#onFinish(boolean,co.cask.cdap.api.mapreduce.MapReduceContext)} method.
 */
private void onFinish(final boolean succeeded) throws TransactionFailureException, InterruptedException {
  runUserCodeInTx(new TransactionExecutor.Procedure<MapReduceContext>(){
    @Override public void apply(    MapReduceContext context) throws Exception {
      mapReduce.onFinish(succeeded,context);
    }
  }
,"String_Node_Str");
}
Program: 7387
Project: 7387
Buggy source:
/** 
 * Calls the   {@link MapReduce#beforeSubmit(co.cask.cdap.api.mapreduce.MapReduceContext)} method.
 */
private void beforeSubmit() throws TransactionFailureException, InterruptedException {
  runUserCodeInTx(new TransactionExecutor.Procedure<MapReduceContext>(){
    @Override public void apply(    MapReduceContext context) throws Exception {
      mapReduce.beforeSubmit(context);
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Calls the   {@link MapReduce#beforeSubmit(co.cask.cdap.api.mapreduce.MapReduceContext)} method.
 */
private void beforeSubmit() throws TransactionFailureException, InterruptedException {
  runUserCodeInTx(new TransactionExecutor.Procedure<MapReduceContext>(){
    @Override public void apply(    MapReduceContext context) throws Exception {
      mapReduce.beforeSubmit(context);
    }
  }
,"String_Node_Str");
}
Program: 7388
Project: 7388
Buggy source:
/** 
 * Stops the Spark program by calling   {@link org.apache.spark.SparkContext#stop()}
 */
public static void stopSparkProgram(){
  sparkContextStopBugFixer();
  if (isScalaProgram()) {
    ((org.apache.spark.SparkContext)getSparkContext().getOriginalSparkContext()).stop();
  }
 else {
    ((org.apache.spark.api.java.JavaSparkContext)getSparkContext().getOriginalSparkContext()).stop();
  }
}

Fixed version (ground truth):
/** 
 * Stops the Spark program by calling   {@link org.apache.spark.SparkContext#stop()}
 */
public static void stopSparkProgram(){
  if (getSparkContext() != null) {
    if (isScalaProgram()) {
      ((org.apache.spark.SparkContext)getSparkContext().getOriginalSparkContext()).stop();
    }
 else {
      ((org.apache.spark.api.java.JavaSparkContext)getSparkContext().getOriginalSparkContext()).stop();
    }
  }
}
Program: 7389
Project: 7389
Buggy source:
/** 
 * @return {@link SparkContext}
 */
public static SparkContext getSparkContext(){
  return sparkContext;
}

Fixed version (ground truth):
/** 
 * @return {@link SparkContext}
 */
private static SparkContext getSparkContext(){
  return sparkContext;
}
Program: 7390
Project: 7390
Buggy source:
@Override public void leader(){
  LOG.info("String_Node_Str");
  resourceCoordinator=new ResourceCoordinator(zkClient,discoveryServiceClient,new BalancedAssignmentStrategy());
  resourceCoordinator.startAndWait();
  try {
    ResourceRequirement.Builder builder=ResourceRequirement.builder(Constants.Service.STREAMS);
    for (    StreamSpecification spec : streamMetaStore.listStreams()) {
      LOG.debug("String_Node_Str",spec.getName());
      builder.addPartition(new ResourceRequirement.Partition(spec.getName(),1));
    }
    resourceCoordinatorClient.submitRequirement(builder.build()).get();
  }
 catch (  Throwable e) {
    LOG.error("String_Node_Str",e);
    Throwables.propagate(e);
  }
}

Fixed version (ground truth):
@Override public void leader(){
  LOG.info("String_Node_Str");
  resourceCoordinator=new ResourceCoordinator(zkClient,discoveryServiceClient,new BalancedAssignmentStrategy());
  resourceCoordinator.startAndWait();
  resourceCoordinatorClient.modifyRequirement(Constants.Service.STREAMS,new ResourceModifier(){
    @Nullable @Override public ResourceRequirement apply(    @Nullable ResourceRequirement existingRequirement){
      try {
        ResourceRequirement.Builder builder=ResourceRequirement.builder(Constants.Service.STREAMS);
        for (        StreamSpecification spec : streamMetaStore.listStreams()) {
          LOG.debug("String_Node_Str",spec.getName());
          builder.addPartition(new ResourceRequirement.Partition(spec.getName(),1));
        }
        return builder.build();
      }
 catch (      Throwable e) {
        LOG.error("String_Node_Str",e);
        Throwables.propagate(e);
        return null;
      }
    }
  }
);
}