nus-yam/ex-repair huggingface dataset:
Program: 25443
Project: 25443
Buggy source:
public void addFlowMod(Long dpid,String sliceName,OFFlowMod flow){
  FSFWOFFlowStatisticsReply flowStat=new FSFWOFFlowStatisticsReply();
  flowStat.setMatch(flow.getMatch());
  flowStat.setActions(flow.getActions());
  flowStat.setPacketCount(0);
  flowStat.setByteCount(0);
  flowStat.setPriority(flow.getPriority());
  flowStat.setCookie(flow.getCookie());
  flowStat.setHardTimeout(flow.getHardTimeout());
  flowStat.setIdleTimeout(flow.getIdleTimeout());
  short length=0;
  for (  OFAction act : flowStat.getActions()) {
    length+=act.getLengthU();
  }
  flowStat.setLength((short)(OFFlowStatisticsReply.MINIMUM_LENGTH + length));
  if (sliced.containsKey(dpid)) {
    HashMap<String,List<OFStatistics>> sliceStats=sliced.get(dpid);
    if (sliceStats.containsKey(sliceName)) {
      log.debug("String_Node_Str");
      sliceStats.get(sliceName).add(flowStat);
      log.debug("String_Node_Str" + sliceStats.get(sliceName).size());
    }
 else {
      List<OFStatistics> stats=new ArrayList<OFStatistics>();
      log.debug("String_Node_Str");
      stats.add(flowStat);
      sliceStats.put(sliceName,stats);
    }
  }
 else {
    HashMap<String,List<OFStatistics>> sliceStats=new HashMap<String,List<OFStatistics>>();
    List<OFStatistics> stats=new ArrayList<OFStatistics>();
    sliceStats.put(sliceName,stats);
    stats.add(flowStat);
    log.debug("String_Node_Str");
    sliced.put(dpid,sliceStats);
  }
  log.debug("String_Node_Str" + flowStat.toString() + "String_Node_Str");
  flowStat.setLastSeen(System.currentTimeMillis());
}

Fixed version (ground truth):
public synchronized void addFlowMod(Long dpid,String sliceName,OFFlowMod flow){
  FSFWOFFlowStatisticsReply flowStat=new FSFWOFFlowStatisticsReply();
  flowStat.setMatch(flow.getMatch());
  flowStat.setActions(flow.getActions());
  flowStat.setPacketCount(0);
  flowStat.setByteCount(0);
  flowStat.setPriority(flow.getPriority());
  flowStat.setCookie(flow.getCookie());
  flowStat.setHardTimeout(flow.getHardTimeout());
  flowStat.setIdleTimeout(flow.getIdleTimeout());
  short length=0;
  for (  OFAction act : flowStat.getActions()) {
    length+=act.getLengthU();
  }
  flowStat.setLength((short)(OFFlowStatisticsReply.MINIMUM_LENGTH + length));
  if (sliced.containsKey(dpid)) {
    HashMap<String,List<OFStatistics>> sliceStats=sliced.get(dpid);
    if (sliceStats.containsKey(sliceName)) {
      log.debug("String_Node_Str");
      sliceStats.get(sliceName).add(flowStat);
      log.debug("String_Node_Str" + sliceStats.get(sliceName).size());
    }
 else {
      List<OFStatistics> stats=new ArrayList<OFStatistics>();
      log.debug("String_Node_Str");
      stats.add(flowStat);
      sliceStats.put(sliceName,stats);
    }
  }
 else {
    HashMap<String,List<OFStatistics>> sliceStats=new HashMap<String,List<OFStatistics>>();
    List<OFStatistics> stats=new ArrayList<OFStatistics>();
    sliceStats.put(sliceName,stats);
    stats.add(flowStat);
    log.debug("String_Node_Str");
    sliced.put(dpid,sliceStats);
  }
  log.debug("String_Node_Str" + flowStat.toString() + "String_Node_Str");
  flowStat.setLastSeen(System.currentTimeMillis());
}
Program: 25444
Project: 25444
Buggy source:
public void writeObject(ObjectOutputStream aOutputStream) throws IOException {
  aOutputStream.writeObject(sliced.clone());
}

Fixed version (ground truth):
public synchronized void writeObject(ObjectOutputStream aOutputStream) throws IOException {
  aOutputStream.writeObject(sliced.clone());
}
Program: 25445
Project: 25445
Buggy source:
public void delFlowMod(long dpid,String sliceName,OFFlowMod flow){
  FSFWOFFlowStatisticsReply flowStat=(FSFWOFFlowStatisticsReply)this.findCachedStat(dpid,flow.getMatch(),sliceName);
  if (flowStat != null) {
    log.error("String_Node_Str");
    flowStat.setToBeDeleted(true);
    return;
  }
  log.error("String_Node_Str");
}

Fixed version (ground truth):
public synchronized void delFlowMod(long dpid,String sliceName,OFFlowMod flow){
  FSFWOFFlowStatisticsReply flowStat=(FSFWOFFlowStatisticsReply)this.findCachedStat(dpid,flow.getMatch(),sliceName);
  if (flowStat != null) {
    log.error("String_Node_Str");
    flowStat.setToBeDeleted(true);
    return;
  }
  log.error("String_Node_Str");
}
Program: 25447
Project: 25447
Buggy source:
public static List<OFStatistics> SliceStats(Slicer slicer,List<OFStatistics> stats){
  List<OFStatistics> reply=new ArrayList<OFStatistics>();
  if (stats == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  log.debug("String_Node_Str" + stats.toString());
  Iterator<OFStatistics> it=stats.iterator();
  while (it.hasNext()) {
    OFFlowStatisticsReply flowStat=(OFFlowStatisticsReply)it.next();
    OFFlowMod flowMod=new OFFlowMod();
    flowMod.setMatch(flowStat.getMatch());
    flowMod.setActions(flowStat.getActions());
    log.debug("String_Node_Str" + flowStat.toString());
    log.debug("String_Node_Str" + flowMod.toString());
    List<OFFlowMod> flowMods=slicer.allowedFlows(flowMod);
    if (flowMods.size() != 0) {
      if (slicer.getTagManagement()) {
        List<OFAction> actions=flowStat.getActions();
        List<OFAction> newActions=new ArrayList<OFAction>();
        for (        OFAction act : actions) {
switch (act.getType()) {
case SET_VLAN_ID:
            flowStat.setLength((short)(flowStat.getLength() - act.getLength()));
          break;
case STRIP_VLAN:
        flowStat.setLength((short)(flowStat.getLength() - act.getLength()));
      break;
default :
    newActions.add(act);
}
}
flowStat.setActions(newActions);
flowStat.getMatch().setWildcards(flowStat.getMatch().getWildcardObj().wildcard(Wildcards.Flag.DL_VLAN));
}
reply.add(flowStat);
}
}
return reply;
}

Fixed version (ground truth):
public static List<OFStatistics> SliceStats(Slicer slicer,List<OFStatistics> stats){
  List<OFStatistics> reply=new ArrayList<OFStatistics>();
  if (stats == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  log.debug("String_Node_Str" + stats.toString());
  Iterator<OFStatistics> it=stats.iterator();
  while (it.hasNext()) {
    OFFlowStatisticsReply flowStat=(OFFlowStatisticsReply)it.next();
    OFFlowMod flowMod=new OFFlowMod();
    flowMod.setMatch(flowStat.getMatch());
    flowMod.setActions(flowStat.getActions());
    log.debug("String_Node_Str" + flowStat.toString());
    log.debug("String_Node_Str" + flowMod.toString());
    List<OFFlowMod> flowMods=slicer.allowedFlows(flowMod);
    if (flowMods.size() != 0) {
      if (slicer.getTagManagement()) {
        List<OFAction> actions=flowStat.getActions();
        List<OFAction> newActions=new ArrayList<OFAction>();
        for (        OFAction act : actions) {
switch (act.getType()) {
case SET_VLAN_ID:
            flowStat.setLength((short)(flowStat.getLength() - act.getLength()));
          break;
case STRIP_VLAN:
        flowStat.setLength((short)(flowStat.getLength() - act.getLength()));
      break;
default :
    newActions.add(act);
}
}
flowStat.setActions(newActions);
flowStat.getMatch().setWildcards(flowStat.getMatch().getWildcardObj().wildcard(Wildcards.Flag.DL_VLAN));
flowStat.getMatch().setDataLayerVirtualLan((short)0);
}
reply.add(flowStat);
}
}
return reply;
}
Program: 25450
Project: 25450
Buggy source:
public List<OFFlowMod> managedFlowActions(OFFlowMod flowMod){
  List<OFFlowMod> newFlows=new ArrayList<OFFlowMod>();
  List<OFAction> actions=flowMod.getActions();
  List<OFAction> newActions=new ArrayList<OFAction>();
  short additional_length=0;
  for (  OFAction act : actions) {
switch (act.getType()) {
case OUTPUT:
      OFActionOutput out=(OFActionOutput)act;
    short vlanTag;
  PortConfig pConfig=this.getPortConfig(out.getPort());
if (pConfig == null) {
  return newFlows;
}
 else {
  vlanTag=(short)pConfig.getVlanRange().getAvailableTags()[0];
}
if (vlanTag == -1) {
OFActionStripVirtualLan strip_vlan_vid=new OFActionStripVirtualLan();
newActions.add(strip_vlan_vid);
additional_length+=strip_vlan_vid.getLength();
}
 else {
OFActionVirtualLanIdentifier set_vlan_vid=new OFActionVirtualLanIdentifier();
set_vlan_vid.setVirtualLanIdentifier(vlanTag);
newActions.add(set_vlan_vid);
additional_length+=set_vlan_vid.getLength();
}
newActions.add(out);
break;
case SET_VLAN_ID:
return newFlows;
case STRIP_VLAN:
return newFlows;
default :
newActions.add(act);
break;
}
}
OFFlowMod newFlow=new OFFlowMod();
newFlow.setMatch(flowMod.getMatch());
newFlow.setActions(newActions);
newFlow.setLength((short)(flowMod.getLength() + additional_length));
newFlows.add(newFlow);
return newFlows;
}

Fixed version (ground truth):
public List<OFFlowMod> managedFlowActions(OFFlowMod flowMod){
  List<OFFlowMod> newFlows=new ArrayList<OFFlowMod>();
  List<OFAction> actions=flowMod.getActions();
  List<OFAction> newActions=new ArrayList<OFAction>();
  short additional_length=0;
  for (  OFAction act : actions) {
switch (act.getType()) {
case OUTPUT:
      OFActionOutput out=(OFActionOutput)act;
    short vlanTag;
  PortConfig pConfig=this.getPortConfig(out.getPort());
if (pConfig == null) {
  return newFlows;
}
 else {
  vlanTag=(short)pConfig.getVlanRange().getAvailableTags()[0];
}
if (vlanTag == -1) {
OFActionStripVirtualLan strip_vlan_vid=new OFActionStripVirtualLan();
newActions.add(strip_vlan_vid);
additional_length+=strip_vlan_vid.getLength();
}
 else {
OFActionVirtualLanIdentifier set_vlan_vid=new OFActionVirtualLanIdentifier();
set_vlan_vid.setVirtualLanIdentifier(vlanTag);
newActions.add(set_vlan_vid);
additional_length+=set_vlan_vid.getLength();
}
newActions.add(out);
break;
case SET_VLAN_ID:
return newFlows;
case STRIP_VLAN:
return newFlows;
default :
newActions.add(act);
break;
}
}
flowMod.setActions(newActions);
flowMod.setLength((short)(flowMod.getLength() + additional_length));
newFlows.add(flowMod);
return newFlows;
}
Program: 25454
Project: 25454
Buggy source:
@Override public void startUp(FloodlightModuleContext context) throws FloodlightModuleException {
  floodlightProvider.addOFSwitchListener(this);
  floodlightProvider.addOFMessageListener(OFType.BARRIER_REPLY,this);
  floodlightProvider.addOFMessageListener(OFType.PACKET_IN,this);
  floodlightProvider.addOFMessageListener(OFType.PORT_MOD,this);
  floodlightProvider.addOFMessageListener(OFType.PORT_STATUS,this);
  floodlightProvider.addOFMessageListener(OFType.ERROR,this);
  switches=new ArrayList<IOFSwitch>();
  statsTimer=new Timer("String_Node_Str");
  statsCacher=new FlowStatCacher(this);
  statsTimer.scheduleAtFixedRate(statsCacher,0,10 * 1000);
  controllerConnectTimer=new Timer("String_Node_Str");
  controllerConnector=new ControllerConnector();
  controllerConnectTimer.scheduleAtFixedRate(controllerConnector,0,10 * 1000);
  restApi.addRestletRoutable(new FlowSpaceFirewallWebRoutable());
}

Fixed version (ground truth):
@Override public void startUp(FloodlightModuleContext context) throws FloodlightModuleException {
  floodlightProvider.addOFSwitchListener(this);
  floodlightProvider.addOFMessageListener(OFType.BARRIER_REPLY,this);
  floodlightProvider.addOFMessageListener(OFType.PACKET_IN,this);
  floodlightProvider.addOFMessageListener(OFType.PORT_MOD,this);
  floodlightProvider.addOFMessageListener(OFType.PORT_STATUS,this);
  floodlightProvider.addOFMessageListener(OFType.ERROR,this);
  floodlightProvider.addOFMessageListener(OFType.FLOW_REMOVED,this);
  switches=new ArrayList<IOFSwitch>();
  statsTimer=new Timer("String_Node_Str");
  statsCacher=new FlowStatCacher(this);
  statsTimer.scheduleAtFixedRate(statsCacher,0,10 * 1000);
  controllerConnectTimer=new Timer("String_Node_Str");
  controllerConnector=new ControllerConnector();
  controllerConnectTimer.scheduleAtFixedRate(controllerConnector,0,10 * 1000);
  restApi.addRestletRoutable(new FlowSpaceFirewallWebRoutable());
}
Program: 25455
Project: 25455
Buggy source:
public FlowTimeout(OFFlowMod flow,int timeout,boolean hard){
  this.flow=flow;
  this.hard=hard;
  this.expires=new Timestamp(System.currentTimeMillis() + (timeout * 1000));
  log.error("String_Node_Str" + this.expires.toString());
  this.timeout=timeout;
  this.packetCount=0;
}

Fixed version (ground truth):
public FlowTimeout(OFFlowMod flow,int timeout,boolean hard,FloodlightContext context){
  this.flow=flow;
  this.hard=hard;
  this.context=context;
  this.expires=new Timestamp(System.currentTimeMillis() + (timeout * 1000));
  log.error("String_Node_Str" + this.expires.toString());
  this.timeout=timeout;
  this.packetCount=0;
}
Program: 25458
Project: 25458
Buggy source:
public void checkExpiredFlows(){
  log.debug("String_Node_Str");
  Iterator<FlowTimeout> it=this.timeouts.iterator();
  while (it.hasNext()) {
    FlowTimeout timeout=it.next();
    if (timeout.isExpired()) {
      log.debug("String_Node_Str");
      it.remove();
      OFFlowMod flow=timeout.getFlow();
      flow.setCommand(OFFlowMod.OFPFC_DELETE_STRICT);
      List<OFAction> actions=new ArrayList<OFAction>();
      flow.setActions(actions);
      flow.setHardTimeout((short)0);
      flow.setIdleTimeout((short)0);
      this.toSwitch((OFMessage)flow,null);
    }
  }
}

Fixed version (ground truth):
public void checkExpiredFlows(){
  log.debug("String_Node_Str");
  Iterator<FlowTimeout> it=this.timeouts.iterator();
  while (it.hasNext()) {
    FlowTimeout timeout=it.next();
    if (timeout.isExpired()) {
      log.debug("String_Node_Str");
      it.remove();
      OFFlowMod flow=timeout.getFlow();
      flow.setOutPort(OFPort.OFPP_NONE);
      flow.setCommand(OFFlowMod.OFPFC_DELETE);
      List<OFAction> actions=new ArrayList<OFAction>();
      flow.setActions(actions);
      flow.setHardTimeout((short)0);
      flow.setIdleTimeout((short)0);
      flow.setFlags(OFFlowMod.OFPFF_SEND_FLOW_REM);
      this.toSwitch((OFMessage)flow,timeout.getContext());
    }
  }
}
Program: 25459
Project: 25459
Buggy source:
@Test public void testFlowTimeoutInit(){
  FlowTimeout timeout=new FlowTimeout(new OFFlowMod(),10,false);
  assertNotNull("String_Node_Str",timeout);
  assertTrue("String_Node_Str",timeout.isHard() == false);
  assertTrue("String_Node_Str",timeout.getPacketCount() == 0);
  assertTrue("String_Node_Str",timeout.isExpired() == false);
  timeout=new FlowTimeout(new OFFlowMod(),100,true);
  assertNotNull("String_Node_Str",timeout);
  assertTrue("String_Node_Str",timeout.isHard());
  assertTrue("String_Node_Str",timeout.getPacketCount() == 0);
  assertTrue("String_Node_Str",timeout.isExpired() == false);
}

Fixed version (ground truth):
@Test public void testFlowTimeoutInit(){
  FlowTimeout timeout=new FlowTimeout(new OFFlowMod(),10,false,null);
  assertNotNull("String_Node_Str",timeout);
  assertTrue("String_Node_Str",timeout.isHard() == false);
  assertTrue("String_Node_Str",timeout.getPacketCount() == 0);
  assertTrue("String_Node_Str",timeout.isExpired() == false);
  timeout=new FlowTimeout(new OFFlowMod(),100,true,null);
  assertNotNull("String_Node_Str",timeout);
  assertTrue("String_Node_Str",timeout.isHard());
  assertTrue("String_Node_Str",timeout.getPacketCount() == 0);
  assertTrue("String_Node_Str",timeout.isExpired() == false);
}
Program: 25460
Project: 25460
Buggy source:
@Test public void testFlowTimeoutSetPacketCount(){
  FlowTimeout timeout=new FlowTimeout(new OFFlowMod(),1,false);
  timeout.setPacketCount((long)100);
  assertTrue("String_Node_Str",timeout.getPacketCount() == 100);
  timeout.setPacketCount((long)1000);
  assertTrue("String_Node_Str",timeout.getPacketCount() == 1000);
}

Fixed version (ground truth):
@Test public void testFlowTimeoutSetPacketCount(){
  FlowTimeout timeout=new FlowTimeout(new OFFlowMod(),1,false,null);
  timeout.setPacketCount((long)100);
  assertTrue("String_Node_Str",timeout.getPacketCount() == 100);
  timeout.setPacketCount((long)1000);
  assertTrue("String_Node_Str",timeout.getPacketCount() == 1000);
}
Program: 25461
Project: 25461
Buggy source:
@Test public void testFlowTimeoutTimeout() throws InterruptedException {
  FlowTimeout timeout=new FlowTimeout(new OFFlowMod(),1,false);
  assertFalse("String_Node_Str",timeout.isExpired());
  Thread.sleep(2000);
  assertTrue("String_Node_Str",timeout.isExpired());
}

Fixed version (ground truth):
@Test public void testFlowTimeoutTimeout() throws InterruptedException {
  FlowTimeout timeout=new FlowTimeout(new OFFlowMod(),1,false,null);
  assertFalse("String_Node_Str",timeout.isExpired());
  Thread.sleep(2000);
  assertTrue("String_Node_Str",timeout.isExpired());
}
Program: 25462
Project: 25462
Buggy source:
@Test public void testFlowTimeoutUpdateLastUsed() throws InterruptedException {
  FlowTimeout timeout=new FlowTimeout(new OFFlowMod(),10,false);
  assertFalse("String_Node_Str",timeout.isExpired());
  Thread.sleep(5000);
  timeout.updateLastUsed();
  Thread.sleep(7000);
  assertFalse("String_Node_Str",timeout.isExpired());
  Thread.sleep(4000);
  assertTrue("String_Node_Str",timeout.isExpired());
}

Fixed version (ground truth):
@Test public void testFlowTimeoutUpdateLastUsed() throws InterruptedException {
  FlowTimeout timeout=new FlowTimeout(new OFFlowMod(),10,false,null);
  assertFalse("String_Node_Str",timeout.isExpired());
  Thread.sleep(5000);
  timeout.updateLastUsed();
  Thread.sleep(7000);
  assertFalse("String_Node_Str",timeout.isExpired());
  Thread.sleep(4000);
  assertTrue("String_Node_Str",timeout.isExpired());
}
Program: 25463
Project: 25463
Buggy source:
public void checkExpiredFlows(){
  log.debug("String_Node_Str");
  Iterator<FlowTimeout> it=this.timeouts.iterator();
  while (it.hasNext()) {
    FlowTimeout timeout=it.next();
    if (timeout.isExpired()) {
      log.debug("String_Node_Str");
      it.remove();
      OFFlowMod flow=timeout.getFlow();
      flow.setOutPort(OFPort.OFPP_NONE);
      flow.setCommand(OFFlowMod.OFPFC_DELETE);
      List<OFAction> actions=new ArrayList<OFAction>();
      flow.setActions(actions);
      flow.setHardTimeout((short)0);
      flow.setIdleTimeout((short)0);
      flow.setFlags(OFFlowMod.OFPFF_SEND_FLOW_REM);
      this.toSwitch((OFMessage)flow,timeout.getContext());
    }
  }
}

Fixed version (ground truth):
public void checkExpiredFlows(){
  log.debug("String_Node_Str");
  Iterator<FlowTimeout> it=this.timeouts.iterator();
  while (it.hasNext()) {
    FlowTimeout timeout=it.next();
    if (timeout.isExpired()) {
      log.debug("String_Node_Str");
      it.remove();
      OFFlowMod flow=timeout.getFlow();
      flow.setOutPort(OFPort.OFPP_NONE);
      flow.setCommand(OFFlowMod.OFPFC_DELETE_STRICT);
      flow.setHardTimeout((short)0);
      flow.setIdleTimeout((short)0);
      flow.setFlags(OFFlowMod.OFPFF_SEND_FLOW_REM);
      this.toSwitch((OFMessage)flow,timeout.getContext());
    }
  }
}
Program: 25468
Project: 25468
Buggy source:
public List<OFFlowMod> managedFlowActions(OFFlowMod flowMod){
  List<OFFlowMod> newFlows=new ArrayList<OFFlowMod>();
  List<OFAction> actions=flowMod.getActions();
  List<OFAction> newActions=new ArrayList<OFAction>();
  short additional_length=0;
  for (  OFAction act : actions) {
switch (act.getType()) {
case OUTPUT:
      OFActionOutput out=(OFActionOutput)act;
    short vlanTag=(short)this.getPortConfig(out.getPort()).getVlanRange().getAvailableTags()[0];
  if (vlanTag == -1) {
    OFActionStripVirtualLan strip_vlan_vid=new OFActionStripVirtualLan();
    newActions.add(strip_vlan_vid);
    additional_length+=strip_vlan_vid.getLength();
  }
 else {
    OFActionVirtualLanIdentifier set_vlan_vid=new OFActionVirtualLanIdentifier();
    set_vlan_vid.setVirtualLanIdentifier(vlanTag);
    newActions.add(set_vlan_vid);
    additional_length+=set_vlan_vid.getLength();
  }
newActions.add(out);
break;
case SET_VLAN_ID:
return newFlows;
case STRIP_VLAN:
return newFlows;
default :
newActions.add(act);
break;
}
}
OFFlowMod newFlow=new OFFlowMod();
newFlow.setMatch(flowMod.getMatch());
newFlow.setActions(newActions);
newFlow.setLength((short)(flowMod.getLength() + additional_length));
newFlows.add(newFlow);
return newFlows;
}

Fixed version (ground truth):
public List<OFFlowMod> managedFlowActions(OFFlowMod flowMod){
  List<OFFlowMod> newFlows=new ArrayList<OFFlowMod>();
  List<OFAction> actions=flowMod.getActions();
  List<OFAction> newActions=new ArrayList<OFAction>();
  short additional_length=0;
  for (  OFAction act : actions) {
switch (act.getType()) {
case OUTPUT:
      OFActionOutput out=(OFActionOutput)act;
    short vlanTag;
  PortConfig pConfig=this.getPortConfig(out.getPort());
if (pConfig == null) {
  return newFlows;
}
 else {
  vlanTag=(short)pConfig.getVlanRange().getAvailableTags()[0];
}
if (vlanTag == -1) {
OFActionStripVirtualLan strip_vlan_vid=new OFActionStripVirtualLan();
newActions.add(strip_vlan_vid);
additional_length+=strip_vlan_vid.getLength();
}
 else {
OFActionVirtualLanIdentifier set_vlan_vid=new OFActionVirtualLanIdentifier();
set_vlan_vid.setVirtualLanIdentifier(vlanTag);
newActions.add(set_vlan_vid);
additional_length+=set_vlan_vid.getLength();
}
newActions.add(out);
break;
case SET_VLAN_ID:
return newFlows;
case STRIP_VLAN:
return newFlows;
default :
newActions.add(act);
break;
}
}
OFFlowMod newFlow=new OFFlowMod();
newFlow.setMatch(flowMod.getMatch());
newFlow.setActions(newActions);
newFlow.setLength((short)(flowMod.getLength() + additional_length));
newFlows.add(newFlow);
return newFlows;
}
Program: 25469
Project: 25469
Buggy source:
/** 
 * test creating the vlan range based on an array of shorts and allowed or not allowed
 */
@Test public void testParamInitFalse(){
  short[] allowed=new short[10];
  allowed[0]=1;
  allowed[1]=150;
  allowed[2]=2;
  allowed[3]=4;
  allowed[4]=4095;
  allowed[5]=-1;
  allowed[6]=5;
  allowed[7]=100;
  allowed[8]=1000;
  allowed[9]=4000;
  VLANRange range=new VLANRange(allowed,false);
  assertNotNull("String_Node_Str",range);
  assertFalse("String_Node_Str",range.getVlanAvail((short)1));
  assertFalse("String_Node_Str",range.getVlanAvail((short)1000));
  assertFalse("String_Node_Str",range.getVlanAvail((short)2));
  assertTrue("String_Node_Str",range.getVlanAvail((short)3));
  assertTrue("String_Node_Str",range.getVlanAvail((short)101));
  assertFalse("String_Node_Str",range.getVlanAvail((short)4000));
  assertFalse("String_Node_Str",range.getVlanAvail((short)4095));
  assertFalse("String_Node_Str",range.getVlanAvail((short)150));
  assertFalse("String_Node_Str",range.getVlanAvail((short)-1));
}

Fixed version (ground truth):
/** 
 * test creating the vlan range based on an array of shorts and allowed or not allowed
 */
@Test public void testParamInitFalse(){
  short[] allowed=new short[10];
  allowed[0]=1;
  allowed[1]=150;
  allowed[2]=2;
  allowed[3]=4;
  allowed[4]=4095;
  allowed[5]=-1;
  allowed[6]=5;
  allowed[7]=100;
  allowed[8]=1000;
  allowed[9]=4000;
  VLANRange range=new VLANRange(allowed,false);
  assertNotNull("String_Node_Str",range);
  assertFalse("String_Node_Str",range.getVlanAvail((short)1));
  assertFalse("String_Node_Str",range.getVlanAvail((short)1000));
  assertFalse("String_Node_Str",range.getVlanAvail((short)2));
  assertTrue("String_Node_Str",range.getVlanAvail((short)3));
  assertTrue("String_Node_Str",range.getVlanAvail((short)101));
  assertFalse("String_Node_Str",range.getVlanAvail((short)4000));
  assertFalse("String_Node_Str",range.getVlanAvail((short)4095));
  assertFalse("String_Node_Str",range.getVlanAvail((short)150));
  assertFalse("String_Node_Str",range.getVlanAvail((short)-1));
  Short[] avail=range.getAvailableTags();
  assertTrue(avail.length == 4086);
  assertTrue(avail[0] == 3);
  assertTrue(avail[1] == 6);
  assertTrue(avail[2] == 7);
  assertTrue(avail[3] == 8);
}
Program: 25470
Project: 25470
Buggy source:
/** 
 * test creating the vlan range based on an array of shorts and allowed or not allowed
 */
@Test public void testParamInit(){
  short[] allowed=new short[10];
  allowed[0]=1;
  allowed[1]=150;
  allowed[2]=2;
  allowed[3]=4;
  allowed[4]=4095;
  allowed[5]=-1;
  allowed[6]=5;
  allowed[7]=100;
  allowed[8]=1000;
  allowed[9]=4000;
  VLANRange range=new VLANRange(allowed,true);
  assertNotNull("String_Node_Str",range);
  assertTrue("String_Node_Str",range.getVlanAvail((short)1));
  assertTrue("String_Node_Str",range.getVlanAvail((short)1000));
  assertTrue("String_Node_Str",range.getVlanAvail((short)2));
  assertFalse("String_Node_Str",range.getVlanAvail((short)3));
  assertFalse("String_Node_Str",range.getVlanAvail((short)101));
  assertTrue("String_Node_Str",range.getVlanAvail((short)4000));
  assertTrue("String_Node_Str",range.getVlanAvail((short)4095));
  assertTrue("String_Node_Str",range.getVlanAvail((short)150));
  assertTrue("String_Node_Str",range.getVlanAvail((short)-1));
}

Fixed version (ground truth):
/** 
 * test creating the vlan range based on an array of shorts and allowed or not allowed
 */
@Test public void testParamInit(){
  short[] allowed=new short[10];
  allowed[0]=1;
  allowed[1]=150;
  allowed[2]=2;
  allowed[3]=4;
  allowed[4]=4095;
  allowed[5]=-1;
  allowed[6]=5;
  allowed[7]=100;
  allowed[8]=1000;
  allowed[9]=4000;
  VLANRange range=new VLANRange(allowed,true);
  assertNotNull("String_Node_Str",range);
  assertTrue("String_Node_Str",range.getVlanAvail((short)1));
  assertTrue("String_Node_Str",range.getVlanAvail((short)1000));
  assertTrue("String_Node_Str",range.getVlanAvail((short)2));
  assertFalse("String_Node_Str",range.getVlanAvail((short)3));
  assertFalse("String_Node_Str",range.getVlanAvail((short)101));
  assertTrue("String_Node_Str",range.getVlanAvail((short)4000));
  assertTrue("String_Node_Str",range.getVlanAvail((short)4095));
  assertTrue("String_Node_Str",range.getVlanAvail((short)150));
  assertTrue("String_Node_Str",range.getVlanAvail((short)-1));
  Short[] avail=range.getAvailableTags();
  assertTrue(avail.length == 10);
  assertTrue(avail[0] == 1);
  assertTrue(avail[1] == 150);
  assertTrue(avail[2] == 2);
  assertTrue(avail[3] == 4);
}
Program: 25471
Project: 25471
Buggy source:
/** 
 * tests setting each vlan range independently
 */
@Test public void setVlanAvail(){
  VLANRange range=new VLANRange();
  range.setVlanAvail((short)1,true);
  range.setVlanAvail((short)2,true);
  range.setVlanAvail((short)3,false);
  range.setVlanAvail((short)4,true);
  range.setVlanAvail((short)5,true);
  range.setVlanAvail((short)100,true);
  range.setVlanAvail((short)4000,true);
  range.setVlanAvail((short)-1,true);
  assertTrue("String_Node_Str",range.getVlanAvail((short)1));
  assertFalse("String_Node_Str",range.getVlanAvail((short)1000));
  assertTrue("String_Node_Str",range.getVlanAvail((short)2));
  assertFalse("String_Node_Str",range.getVlanAvail((short)3));
  assertFalse("String_Node_Str",range.getVlanAvail((short)101));
  assertTrue("String_Node_Str",range.getVlanAvail((short)100));
  assertTrue("String_Node_Str",range.getVlanAvail((short)4000));
  assertTrue("String_Node_Str",range.getVlanAvail((short)-1));
}

Fixed version (ground truth):
/** 
 * tests setting each vlan range independently
 */
@Test public void setVlanAvail(){
  VLANRange range=new VLANRange();
  range.setVlanAvail((short)1,true);
  range.setVlanAvail((short)2,true);
  range.setVlanAvail((short)3,false);
  range.setVlanAvail((short)4,true);
  range.setVlanAvail((short)5,true);
  range.setVlanAvail((short)100,true);
  range.setVlanAvail((short)4000,true);
  range.setVlanAvail((short)-1,true);
  assertTrue("String_Node_Str",range.getVlanAvail((short)1));
  assertFalse("String_Node_Str",range.getVlanAvail((short)1000));
  assertTrue("String_Node_Str",range.getVlanAvail((short)2));
  assertFalse("String_Node_Str",range.getVlanAvail((short)3));
  assertFalse("String_Node_Str",range.getVlanAvail((short)101));
  assertTrue("String_Node_Str",range.getVlanAvail((short)100));
  assertTrue("String_Node_Str",range.getVlanAvail((short)4000));
  assertTrue("String_Node_Str",range.getVlanAvail((short)-1));
  Short[] avail=range.getAvailableTags();
  assertTrue(avail.length == 7);
  assertTrue(avail[0] == 1);
  assertTrue(avail[1] == 2);
  assertTrue(avail[2] == 4);
  assertTrue(avail[3] == 5);
  assertTrue(avail[4] == 100);
  assertTrue(avail[5] == 4000);
  assertTrue(avail[6] == -1);
}
Program: 25472
Project: 25472
Buggy source:
public boolean setSliceAdminState(Long dpid,String sliceName,boolean state){
  List<Proxy> proxies=this.controllerConnector.getSwitchProxies(dpid);
  for (  Proxy p : proxies) {
    if (p.getSlicer().getSliceName().equals(sliceName)) {
      p.setAdminStatus(state);
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
public boolean setSliceAdminState(Long dpid,String sliceName,boolean state){
  List<Proxy> proxies=this.controllerConnector.getSwitchProxies(dpid);
  for (  Proxy p : proxies) {
    if (p.getSlicer().getSliceName().equals(sliceName)) {
      logger.info("String_Node_Str" + sliceName + "String_Node_Str"+ state);
      p.setAdminStatus(state);
      return true;
    }
  }
  return false;
}
Program: 25473
Project: 25473
Buggy source:
public Proxy(IOFSwitch switchImp,Slicer slicer,FlowSpaceFirewall fsf){
  mySlicer=slicer;
  mySwitch=switchImp;
  mySlicer.setSwitch(mySwitch);
  parent=fsf;
  flowCount=0;
  xidMap=new XidMap();
  adminStatus=true;
  packetInRate=new RateTracker(100,slicer.getPacketInRate());
}

Fixed version (ground truth):
public Proxy(IOFSwitch switchImp,Slicer slicer,FlowSpaceFirewall fsf){
  mySlicer=slicer;
  mySwitch=switchImp;
  mySlicer.setSwitch(mySwitch);
  parent=fsf;
  flowCount=0;
  xidMap=new XidMap();
  adminStatus=mySlicer.getAdminState();
  packetInRate=new RateTracker(100,slicer.getPacketInRate());
}
Program: 25474
Project: 25474
Buggy source:
public void setAdminStatus(Boolean status){
  adminStatus=status;
  if (status) {
    log.warn("String_Node_Str" + this.mySlicer.getSliceName() + "String_Node_Str");
  }
 else {
    log.error("String_Node_Str" + this.mySlicer.getSliceName());
    this.removeFlows();
    this.disconnect();
  }
}

Fixed version (ground truth):
public void setAdminStatus(Boolean status){
  this.adminStatus=status;
  this.mySlicer.setAdminState(status);
  if (status) {
    log.warn("String_Node_Str" + this.mySlicer.getSliceName() + "String_Node_Str");
  }
 else {
    log.error("String_Node_Str" + this.mySlicer.getSliceName());
    if (this.connected()) {
      this.removeFlows();
      this.disconnect();
    }
  }
}
Program: 25475
Project: 25475
Buggy source:
public void removeFlows(){
  List<OFStatistics> stats=this.parent.getStats(mySwitch.getId());
  List<OFStatistics> results=null;
  try {
    results=FlowStatSlicer.SliceStats(mySlicer,stats);
  }
 catch (  IllegalArgumentException e) {
  }
  if (results == null) {
    log.debug("String_Node_Str");
    return;
  }
  List<OFMessage> deletes=new ArrayList<OFMessage>();
  for (  OFStatistics stat : results) {
    OFFlowStatisticsReply flowStat=(OFFlowStatisticsReply)stat;
    OFFlowMod flow=new OFFlowMod();
    flow.setMatch(flowStat.getMatch());
    flow.setActions(flowStat.getActions());
    flow.setLengthU(OFFlowMod.MAXIMUM_LENGTH);
    flow.setCommand(OFFlowMod.OFPFC_DELETE);
    deletes.add(flow);
  }
  try {
    this.mySwitch.write(deletes,null);
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public void removeFlows(){
  List<OFStatistics> results=this.parent.getSlicedFlowStats(mySwitch.getId(),this.mySlicer.getSliceName());
  if (results == null) {
    log.debug("String_Node_Str");
    return;
  }
  List<OFMessage> deletes=new ArrayList<OFMessage>();
  for (  OFStatistics stat : results) {
    OFFlowStatisticsReply flowStat=(OFFlowStatisticsReply)stat;
    OFFlowMod flow=new OFFlowMod();
    flow.setMatch(flowStat.getMatch());
    flow.setActions(flowStat.getActions());
    int length=0;
    for (    OFAction act : flow.getActions()) {
      length+=act.getLength();
    }
    flow.setLengthU(OFFlowMod.MINIMUM_LENGTH + length);
    flow.setCommand(OFFlowMod.OFPFC_DELETE);
    deletes.add(flow);
  }
  try {
    this.mySwitch.write(deletes,null);
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}
Program: 25476
Project: 25476
Buggy source:
public VLANSlicer(){
  myRateTracker=new RateTracker(10,100);
  packetInRate=10;
  portList=new HashMap<String,PortConfig>();
  name="String_Node_Str";
  this.bufferIds=Collections.synchronizedMap(new LinkedHashMap<Integer,byte[]>(){
    /** 
 */
    private static final long serialVersionUID=1L;
    @Override public boolean removeEldestEntry(    Map.Entry<Integer,byte[]> eldest){
      return size() >= 1000;
    }
  }
);
}

Fixed version (ground truth):
public VLANSlicer(){
  myRateTracker=new RateTracker(10,100);
  packetInRate=10;
  portList=new HashMap<String,PortConfig>();
  name="String_Node_Str";
  this.adminState=true;
  this.bufferIds=Collections.synchronizedMap(new LinkedHashMap<Integer,byte[]>(){
    /** 
 */
    private static final long serialVersionUID=1L;
    @Override public boolean removeEldestEntry(    Map.Entry<Integer,byte[]> eldest){
      return size() >= 1000;
    }
  }
);
}
Program: 25478
Project: 25478
Buggy source:
/** 
 * slice requests from the controller to the switch. if a message isn't allowed then return with the sendError
 * @param msg
 * @param cntx
 */
public void toSwitch(OFMessage msg,FloodlightContext cntx){
  log.debug("String_Node_Str" + msg.getType());
  if (!this.mySlicer.isOkToProcessMessage()) {
    log.warn("String_Node_Str" + this.mySwitch.getStringId() + "String_Node_Str"+ this.mySlicer.getSliceName()+ "String_Node_Str");
    this.sendError((OFMessage)msg);
    return;
  }
switch (msg.getType()) {
case FLOW_MOD:
    processFlowMod(msg,cntx);
  return;
case PACKET_OUT:
List<OFMessage> allowed=this.mySlicer.allowedPacketOut((OFPacketOut)msg);
if (allowed.isEmpty()) {
log.info("String_Node_Str");
this.sendError((OFMessage)msg);
return;
}
 else {
log.info("String_Node_Str");
mapXids(allowed);
try {
  mySwitch.write(allowed,cntx);
}
 catch (IOException e) {
  e.printStackTrace();
}
mySwitch.flush();
}
return;
case STATS_REQUEST:
handleStatsRequest(msg);
return;
case PORT_MOD:
this.sendError((OFMessage)msg);
return;
case SET_CONFIG:
this.sendError((OFMessage)msg);
return;
default :
break;
}
mapXids(msg);
if (!this.valid_header(msg)) {
log.error("String_Node_Str" + this.getSlicer().getSliceName() + "String_Node_Str"+ this.mySwitch.getStringId()+ "String_Node_Str");
return;
}
try {
mySwitch.write(msg,cntx);
}
 catch (IOException e) {
e.printStackTrace();
}
mySwitch.flush();
}

Fixed version (ground truth):
/** 
 * slice requests from the controller to the switch. if a message isn't allowed then return with the sendError
 * @param msg
 * @param cntx
 */
public void toSwitch(OFMessage msg,FloodlightContext cntx){
  log.debug("String_Node_Str" + msg.getType());
  if (!this.mySlicer.isOkToProcessMessage()) {
    log.warn("String_Node_Str" + this.mySwitch.getStringId() + "String_Node_Str"+ this.mySlicer.getSliceName()+ "String_Node_Str");
    this.sendError((OFMessage)msg);
    return;
  }
switch (msg.getType()) {
case FLOW_MOD:
    processFlowMod(msg,cntx);
  return;
case PACKET_OUT:
List<OFMessage> allowed=this.mySlicer.allowedPacketOut((OFPacketOut)msg);
if (allowed.isEmpty()) {
log.info("String_Node_Str");
this.sendError((OFMessage)msg);
return;
}
 else {
log.debug("String_Node_Str");
mapXids(allowed);
try {
  mySwitch.write(allowed,cntx);
}
 catch (IOException e) {
  e.printStackTrace();
}
mySwitch.flush();
}
return;
case STATS_REQUEST:
handleStatsRequest(msg);
return;
case PORT_MOD:
this.sendError((OFMessage)msg);
return;
case SET_CONFIG:
this.sendError((OFMessage)msg);
return;
default :
break;
}
mapXids(msg);
if (!this.valid_header(msg)) {
log.error("String_Node_Str" + this.getSlicer().getSliceName() + "String_Node_Str"+ this.mySwitch.getStringId()+ "String_Node_Str");
return;
}
try {
mySwitch.write(msg,cntx);
}
 catch (IOException e) {
e.printStackTrace();
}
mySwitch.flush();
}
Program: 25481
Project: 25481
Buggy source:
public synchronized List<HashMap<Long,Slicer>> getSlices(){
  List<HashMap<Long,Slicer>> slices=Collections.synchronizedList(this.slices);
synchronized (slices) {
    logger.error("String_Node_Str" + slices.size());
    return slices;
  }
}

Fixed version (ground truth):
public synchronized List<HashMap<Long,Slicer>> getSlices(){
  List<HashMap<Long,Slicer>> slices=Collections.synchronizedList(this.slices);
  logger.error("String_Node_Str" + slices.size());
  return slices;
}
Program: 25482
Project: 25482
Buggy source:
public synchronized void removeSlice(long dpid,String name){
  for (  HashMap<Long,Slicer> hash : this.slices) {
    if (hash.containsKey(dpid)) {
      if (hash.get(dpid).getSliceName().equals(name)) {
        hash.remove(dpid);
        return;
      }
    }
  }
  for (int i=0; i < this.slices.size(); i++) {
    HashMap<Long,Slicer> tmp=this.slices.get(i);
    if (tmp.isEmpty()) {
      this.slices.remove(i);
    }
  }
}

Fixed version (ground truth):
public synchronized void removeSlice(long dpid,String name){
  for (  HashMap<Long,Slicer> hash : this.slices) {
    if (hash.containsKey(dpid)) {
      if (hash.get(dpid).getSliceName().equals(name)) {
        hash.remove(dpid);
      }
    }
  }
  for (int i=0; i < this.slices.size(); i++) {
    HashMap<Long,Slicer> tmp=this.slices.get(i);
    if (tmp.isEmpty()) {
      this.slices.remove(i);
    }
  }
}
Program: 25483
Project: 25483
Buggy source:
/** 
 * get a list of proxies for a given switch
 * @param switchId (Long)
 * @return List <Proxy> getSwitchProxiessynchronized for thread safty
 */
public synchronized List<Proxy> getSwitchProxies(Long switchId){
  log.debug("String_Node_Str" + switchId);
  Set<Long> keys=proxies.keySet();
  Iterator<Long> it=keys.iterator();
  while (it.hasNext()) {
    Long key=it.next();
    log.debug("String_Node_Str" + key);
  }
  return proxies.get(switchId);
}

Fixed version (ground truth):
/** 
 * get a list of proxies for a given switch
 * @param switchId (Long)
 * @return List <Proxy> getSwitchProxiessynchronized for thread safty
 */
public synchronized List<Proxy> getSwitchProxies(Long switchId){
  log.debug("String_Node_Str" + switchId);
  return proxies.get(switchId);
}
Program: 25484
Project: 25484
Buggy source:
public List<HashMap<Long,Slicer>> getSlices(){
  List<HashMap<Long,Slicer>> slices=Collections.synchronizedList(this.slices);
synchronized (slices) {
    logger.error("String_Node_Str" + slices.size());
    return slices;
  }
}

Fixed version (ground truth):
public synchronized List<HashMap<Long,Slicer>> getSlices(){
  List<HashMap<Long,Slicer>> slices=Collections.synchronizedList(this.slices);
synchronized (slices) {
    logger.error("String_Node_Str" + slices.size());
    return slices;
  }
}
Program: 25485
Project: 25485
Buggy source:
public HashMap<Long,Slicer> getSlice(String name){
  List<HashMap<Long,Slicer>> mySlices=Collections.synchronizedList(this.slices);
synchronized (mySlices) {
    Iterator<HashMap<Long,Slicer>> it=mySlices.iterator();
    while (it.hasNext()) {
      HashMap<Long,Slicer> slice=it.next();
      Iterator<Long> dpidIt=slice.keySet().iterator();
      if (dpidIt.hasNext()) {
        Long dpid=dpidIt.next();
        if (slice.get(dpid).getSliceName().equals(name)) {
          return slice;
        }
      }
    }
  }
  return null;
}

Fixed version (ground truth):
public synchronized HashMap<Long,Slicer> getSlice(String name){
  List<HashMap<Long,Slicer>> mySlices=Collections.synchronizedList(this.slices);
  Iterator<HashMap<Long,Slicer>> it=mySlices.iterator();
  while (it.hasNext()) {
    HashMap<Long,Slicer> slice=it.next();
    Iterator<Long> dpidIt=slice.keySet().iterator();
    if (dpidIt.hasNext()) {
      Long dpid=dpidIt.next();
      if (slice.get(dpid).getSliceName().equals(name)) {
        return slice;
      }
    }
  }
  return null;
}
Program: 25487
Project: 25487
Buggy source:
/** 
 * Removes a switch from the list of switches
 * @param sw
 */
public void removeSwitch(IOFSwitch sw){
  mySwitches.remove(sw);
}

Fixed version (ground truth):
/** 
 * Removes a switch from the list of switches
 * @param sw
 */
public synchronized void removeSwitch(IOFSwitch sw){
  mySwitches.remove(sw);
}
Program: 25488
Project: 25488
Buggy source:
/** 
 * Adds a switch to the list of Switches
 * @param sw
 */
public void addSwitch(IOFSwitch sw){
  mySwitches.add(sw);
}

Fixed version (ground truth):
/** 
 * Adds a switch to the list of Switches
 * @param sw
 */
public synchronized void addSwitch(IOFSwitch sw){
  mySwitches.add(sw);
}
Program: 25489
Project: 25489
Buggy source:
/** 
 * disconnect from the controller
 */
public void disconnect(){
  myController.disconnect();
  myController.close();
}

Fixed version (ground truth):
/** 
 * disconnect from the controller
 */
public void disconnect(){
  if (myController.isConnected()) {
    myController.disconnect();
    myController.close();
  }
}
Program: 25490
Project: 25490
Buggy source:
/** 
 * sets the slicer if for example the config is updated
 * @param newSlicer
 */
public void setSlicer(Slicer newSlicer){
  if (newSlicer.getControllerAddress().equals(this.mySlicer.getControllerAddress())) {
    this.disconnect();
  }
  this.mySlicer=newSlicer;
  this.mySlicer.setSwitch(this.mySwitch);
  this.packetInRate.setRate(this.getSlicer().getPacketInRate());
}

Fixed version (ground truth):
/** 
 * sets the slicer if for example the config is updated
 * @param newSlicer
 */
public void setSlicer(Slicer newSlicer){
  if (!newSlicer.getControllerAddress().equals(this.mySlicer.getControllerAddress())) {
    this.disconnect();
  }
  this.mySlicer=newSlicer;
  this.mySlicer.setSwitch(this.mySwitch);
  this.packetInRate.setRate(this.getSlicer().getPacketInRate());
}
Program: 25491
Project: 25491
Buggy source:
private void processFlowMod(OFMessage msg){
  List<OFFlowMod> flows=this.mySlicer.allowedFlows((OFFlowMod)msg);
  if (flows.size() == 0) {
    log.info("String_Node_Str");
    this.sendError((OFMessage)msg);
    return;
  }
 else {
    log.info("String_Node_Str");
  }
  List<OFMessage> messages=new ArrayList<OFMessage>();
  Iterator<OFFlowMod> it=flows.iterator();
  while (it.hasNext()) {
    OFFlowMod flow=it.next();
    messages.add((OFMessage)msg);
switch (flow.getCommand()) {
case OFFlowMod.OFPFC_ADD:
      if (this.mySlicer.isGreaterThanMaxFlows(this.flowCount + 1)) {
        log.warn("String_Node_Str");
        this.sendError((OFMessage)msg);
        return;
      }
    this.updateFlowCount(1);
  break;
case OFFlowMod.OFPFF_CHECK_OVERLAP:
if (this.mySlicer.isGreaterThanMaxFlows(this.flowCount + 1)) {
  log.warn("String_Node_Str");
  this.sendError((OFMessage)msg);
  return;
}
this.updateFlowCount(1);
break;
case OFFlowMod.OFPFC_DELETE:
this.updateFlowCount(-1);
break;
case OFFlowMod.OFPFC_DELETE_STRICT:
this.updateFlowCount(-1);
break;
case OFFlowMod.OFPFC_MODIFY:
break;
}
}
mapXids(messages);
try {
mySwitch.write(messages,null);
}
 catch (IOException e) {
e.printStackTrace();
}
mySwitch.flush();
}

Fixed version (ground truth):
private void processFlowMod(OFMessage msg,FloodlightContext cntx){
  List<OFFlowMod> flows=this.mySlicer.allowedFlows((OFFlowMod)msg);
  if (flows.size() == 0) {
    log.info("String_Node_Str");
    this.sendError((OFMessage)msg);
    return;
  }
 else {
    log.info("String_Node_Str");
  }
  List<OFMessage> messages=new ArrayList<OFMessage>();
  Iterator<OFFlowMod> it=flows.iterator();
  while (it.hasNext()) {
    OFFlowMod flow=it.next();
    messages.add((OFMessage)msg);
switch (flow.getCommand()) {
case OFFlowMod.OFPFC_ADD:
      if (this.mySlicer.isGreaterThanMaxFlows(this.flowCount + 1)) {
        log.warn("String_Node_Str");
        this.sendError((OFMessage)msg);
        return;
      }
    this.updateFlowCount(1);
  break;
case OFFlowMod.OFPFF_CHECK_OVERLAP:
if (this.mySlicer.isGreaterThanMaxFlows(this.flowCount + 1)) {
  log.warn("String_Node_Str");
  this.sendError((OFMessage)msg);
  return;
}
this.updateFlowCount(1);
break;
case OFFlowMod.OFPFC_DELETE:
this.updateFlowCount(-1);
break;
case OFFlowMod.OFPFC_DELETE_STRICT:
this.updateFlowCount(-1);
break;
case OFFlowMod.OFPFC_MODIFY:
break;
}
}
mapXids(messages);
try {
mySwitch.write(messages,cntx);
}
 catch (IOException e) {
e.printStackTrace();
}
mySwitch.flush();
}
Program: 25492
Project: 25492
Buggy source:
/** 
 * slice requests from the controller to the switch. if a message isn't allowed then return with the sendError
 * @param msg
 * @param cntx
 */
public void toSwitch(OFMessage msg,FloodlightContext cntx){
  log.debug("String_Node_Str" + msg.getType());
  if (!this.mySlicer.isOkToProcessMessage()) {
    log.warn("String_Node_Str");
    this.sendError((OFMessage)msg);
  }
switch (msg.getType()) {
case FLOW_MOD:
    processFlowMod(msg);
  return;
case PACKET_OUT:
List<OFMessage> allowed=this.mySlicer.allowedPacketOut((OFPacketOut)msg);
if (allowed.isEmpty()) {
log.info("String_Node_Str");
this.sendError((OFMessage)msg);
return;
}
 else {
log.info("String_Node_Str");
mapXids(allowed);
try {
  mySwitch.write(allowed,null);
}
 catch (IOException e) {
  e.printStackTrace();
}
mySwitch.flush();
}
return;
case STATS_REQUEST:
handleStatsRequest(msg);
return;
case PORT_MOD:
this.sendError((OFMessage)msg);
return;
case SET_CONFIG:
this.sendError((OFMessage)msg);
return;
default :
break;
}
mapXids(msg);
try {
mySwitch.write(msg,null);
}
 catch (IOException e) {
e.printStackTrace();
}
mySwitch.flush();
}

Fixed version (ground truth):
/** 
 * slice requests from the controller to the switch. if a message isn't allowed then return with the sendError
 * @param msg
 * @param cntx
 */
public void toSwitch(OFMessage msg,FloodlightContext cntx){
  log.debug("String_Node_Str" + msg.getType());
  if (!this.mySlicer.isOkToProcessMessage()) {
    log.warn("String_Node_Str");
    this.sendError((OFMessage)msg);
    return;
  }
switch (msg.getType()) {
case FLOW_MOD:
    processFlowMod(msg,cntx);
  return;
case PACKET_OUT:
List<OFMessage> allowed=this.mySlicer.allowedPacketOut((OFPacketOut)msg);
if (allowed.isEmpty()) {
log.info("String_Node_Str");
this.sendError((OFMessage)msg);
return;
}
 else {
log.info("String_Node_Str");
mapXids(allowed);
try {
  mySwitch.write(allowed,cntx);
}
 catch (IOException e) {
  e.printStackTrace();
}
mySwitch.flush();
}
return;
case STATS_REQUEST:
handleStatsRequest(msg);
return;
case PORT_MOD:
this.sendError((OFMessage)msg);
return;
case SET_CONFIG:
this.sendError((OFMessage)msg);
return;
default :
break;
}
mapXids(msg);
try {
mySwitch.write(msg,cntx);
}
 catch (IOException e) {
e.printStackTrace();
}
mySwitch.flush();
}
Program: 25494
Project: 25494
Buggy source:
@Get("String_Node_Str") public List<HashMap<Long,Slicer>> Slices(){
  IFlowSpaceFirewallService iFSFs=(IFlowSpaceFirewallService)getContext().getAttributes().get(IFlowSpaceFirewallService.class.getCanonicalName());
  List<HashMap<Long,Slicer>> slices=iFSFs.getSlices();
  return slices;
}

Fixed version (ground truth):
@Get("String_Node_Str") public HashMap<String,List<Slicer>> Slices(){
  IFlowSpaceFirewallService iFSFs=(IFlowSpaceFirewallService)getContext().getAttributes().get(IFlowSpaceFirewallService.class.getCanonicalName());
  List<HashMap<Long,Slicer>> slices=iFSFs.getSlices();
  HashMap<String,List<Slicer>> newSlices=new HashMap<String,List<Slicer>>();
  for (  HashMap<Long,Slicer> slice : slices) {
    for (    Long dpid : slice.keySet()) {
      if (newSlices.containsKey(slice.get(dpid).getSliceName())) {
        List<Slicer> curSlices=newSlices.get(slice.get(dpid).getSliceName());
        curSlices.add(slice.get(dpid));
      }
 else {
        List<Slicer> curSlices=new ArrayList<Slicer>();
        curSlices.add(slice.get(dpid));
        newSlices.put(slice.get(dpid).getSliceName(),curSlices);
      }
    }
  }
  return newSlices;
}
Program: 25495
Project: 25495
Buggy source:
@Get("String_Node_Str") public HashMap<Long,List<Slicer>> getSwitches(){
  IFlowSpaceFirewallService iFSFs=(IFlowSpaceFirewallService)getContext().getAttributes().get(IFlowSpaceFirewallService.class.getCanonicalName());
  List<HashMap<Long,Slicer>> slices=iFSFs.getSlices();
  HashMap<Long,List<Slicer>> results=new HashMap<Long,List<Slicer>>();
  Iterator<HashMap<Long,Slicer>> sliceIt=slices.iterator();
  while (sliceIt.hasNext()) {
    HashMap<Long,Slicer> slice=sliceIt.next();
    Iterator<Long> dpidIt=slice.keySet().iterator();
    while (dpidIt.hasNext()) {
      Long dpid=dpidIt.next();
      if (results.containsKey(dpid)) {
        results.get(dpid).add(slice.get(dpid));
      }
 else {
        ArrayList<Slicer> sliceList=new ArrayList<Slicer>();
        sliceList.add(slice.get(dpid));
        results.put(dpid,sliceList);
      }
    }
  }
  return results;
}

Fixed version (ground truth):
@Get("String_Node_Str") public List<IOFSwitch> getSwitches(){
  IFlowSpaceFirewallService iFSFs=(IFlowSpaceFirewallService)getContext().getAttributes().get(IFlowSpaceFirewallService.class.getCanonicalName());
  return iFSFs.getSwitches();
}