Program: 25465
Project: 25465
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) {
  newFlows.clear();
  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:
log.error("String_Node_Str");
newFlows.clear();
return newFlows;
case STRIP_VLAN:
log.error("String_Node_Str");
newFlows.clear();
return newFlows;
default :
newActions.add(act);
break;
}
}
flowMod.setActions(newActions);
flowMod.setLength((short)(flowMod.getLength() + additional_length));
newFlows.add(flowMod);
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;
  if (out.getPort() == OFPort.OFPP_CONTROLLER.getValue()) {
    newActions.add(out);
    break;
  }
if (out.getPort() == OFPort.OFPP_ALL.getValue()) {
  Iterator<Entry<String,PortConfig>> it=this.portList.entrySet().iterator();
  while (it.hasNext()) {
    Map.Entry<String,PortConfig> port=(Entry<String,PortConfig>)it.next();
    if (port.getValue().getPortId() != 0) {
      PortConfig pConfig=this.getPortConfig(port.getValue().getPortId());
      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();
      }
      OFActionOutput newOut=new OFActionOutput();
      out.setPort(port.getValue().getPortId());
      newActions.add(newOut);
      additional_length+=newOut.getLength();
    }
  }
  additional_length-=out.getLengthU();
  break;
}
PortConfig pConfig=this.getPortConfig(out.getPort());
if (pConfig == null) {
newFlows.clear();
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:
log.error("String_Node_Str");
newFlows.clear();
return newFlows;
case STRIP_VLAN:
log.error("String_Node_Str");
newFlows.clear();
return newFlows;
default :
newActions.add(act);
break;
}
}
flowMod.setActions(newActions);
flowMod.setLength((short)(flowMod.getLength() + additional_length));
newFlows.add(flowMod);
return newFlows;
}