Program: 4409
Project: 4409
Buggy source:
/** 
 * Creates a <tt>List</tt> of <tt>QueryReply</tt> instances with compressed XML data, if requested.
 * @return a new <tt>List</tt> of <tt>QueryReply</tt> instances
 */
protected List createQueryReply(byte[] guid,byte ttl,long speed,Response[] res,byte[] clientGUID,boolean busy,boolean uploaded,boolean measuredSpeed,boolean isFromMcast,boolean canFWTransfer){
  List queryReplies=new ArrayList();
  QueryReply queryReply=null;
  int port=isFromMcast ? RouterService.getNonForcedPort() : RouterService.getPort();
  byte[] ip=isFromMcast ? RouterService.getNonForcedAddress() : (canFWTransfer ? RouterService.getExternalAddress() : RouterService.getAddress());
  String xmlCollectionString=LimeXMLDocumentHelper.getAggregateString(res);
  if (xmlCollectionString == null)   xmlCollectionString="String_Node_Str";
  byte[] xmlBytes=null;
  try {
    xmlBytes=xmlCollectionString.getBytes("String_Node_Str");
  }
 catch (  UnsupportedEncodingException ueex) {
    ErrorService.error(ueex,"String_Node_Str" + xmlCollectionString);
  }
  boolean notIncoming=!RouterService.acceptedIncomingConnection();
  Set proxies=(notIncoming ? _manager.getPushProxies() : null);
  if (xmlBytes.length > QueryReply.XML_MAX_SIZE) {
    List splitResps=new LinkedList();
    splitAndAddResponses(splitResps,res);
    while (!splitResps.isEmpty()) {
      Response[] currResps=(Response[])splitResps.remove(0);
      String currXML=LimeXMLDocumentHelper.getAggregateString(currResps);
      byte[] currXMLBytes=null;
      try {
        currXMLBytes=currXML.getBytes("String_Node_Str");
      }
 catch (      UnsupportedEncodingException ueex) {
        ErrorService.error(ueex,"String_Node_Str" + currXML);
        currXMLBytes="String_Node_Str".getBytes();
      }
      if ((currXMLBytes.length > QueryReply.XML_MAX_SIZE) && (currResps.length > 1))       splitAndAddResponses(splitResps,currResps);
 else {
        byte[] xmlCompressed=null;
        if ((currXML != null) && (!currXML.equals("String_Node_Str")))         xmlCompressed=LimeXMLUtils.compress(currXMLBytes);
 else         xmlCompressed=DataUtils.EMPTY_BYTE_ARRAY;
        queryReply=new QueryReply(guid,ttl,port,ip,speed,currResps,_clientGUID,xmlCompressed,notIncoming,busy,uploaded,measuredSpeed,ChatSettings.CHAT_ENABLED.getValue(),isFromMcast,canFWTransfer,proxies);
        queryReplies.add(queryReply);
      }
    }
  }
 else {
    byte[] xmlCompressed=null;
    if (xmlCollectionString != null && !xmlCollectionString.equals("String_Node_Str"))     xmlCompressed=LimeXMLUtils.compress(xmlBytes);
 else     xmlCompressed=DataUtils.EMPTY_BYTE_ARRAY;
    queryReply=new QueryReply(guid,ttl,port,ip,speed,res,_clientGUID,xmlCompressed,notIncoming,busy,uploaded,measuredSpeed,ChatSettings.CHAT_ENABLED.getValue(),isFromMcast,canFWTransfer,proxies);
    queryReplies.add(queryReply);
  }
  return queryReplies;
}

Fixed version (ground truth):
/** 
 * Creates a <tt>List</tt> of <tt>QueryReply</tt> instances with compressed XML data, if requested.
 * @return a new <tt>List</tt> of <tt>QueryReply</tt> instances
 */
protected List createQueryReply(byte[] guid,byte ttl,long speed,Response[] res,byte[] clientGUID,boolean busy,boolean uploaded,boolean measuredSpeed,boolean isFromMcast,boolean canFWTransfer){
  List queryReplies=new ArrayList();
  QueryReply queryReply=null;
  int port=-1;
  byte[] ip=null;
  if (isFromMcast) {
    ip=RouterService.getNonForcedAddress();
    port=RouterService.getNonForcedPort();
    if (!NetworkUtils.isValidPort(port) || !NetworkUtils.isValidAddress(ip))     isFromMcast=false;
  }
  if (!isFromMcast) {
    port=RouterService.getPort();
    if (!NetworkUtils.isValidPort(port))     return Collections.EMPTY_LIST;
    if (canFWTransfer) {
      ip=RouterService.getExternalAddress();
      if (!NetworkUtils.isValidAddress(ip))       canFWTransfer=false;
    }
    if (!canFWTransfer) {
      ip=RouterService.getAddress();
      if (!NetworkUtils.isValidAddress(ip))       return Collections.EMPTY_LIST;
    }
  }
  String xmlCollectionString=LimeXMLDocumentHelper.getAggregateString(res);
  if (xmlCollectionString == null)   xmlCollectionString="String_Node_Str";
  byte[] xmlBytes=null;
  try {
    xmlBytes=xmlCollectionString.getBytes("String_Node_Str");
  }
 catch (  UnsupportedEncodingException ueex) {
    ErrorService.error(ueex,"String_Node_Str" + xmlCollectionString);
  }
  boolean notIncoming=!RouterService.acceptedIncomingConnection();
  Set proxies=(notIncoming ? _manager.getPushProxies() : null);
  if (xmlBytes.length > QueryReply.XML_MAX_SIZE) {
    List splitResps=new LinkedList();
    splitAndAddResponses(splitResps,res);
    while (!splitResps.isEmpty()) {
      Response[] currResps=(Response[])splitResps.remove(0);
      String currXML=LimeXMLDocumentHelper.getAggregateString(currResps);
      byte[] currXMLBytes=null;
      try {
        currXMLBytes=currXML.getBytes("String_Node_Str");
      }
 catch (      UnsupportedEncodingException ueex) {
        ErrorService.error(ueex,"String_Node_Str" + currXML);
        currXMLBytes="String_Node_Str".getBytes();
      }
      if ((currXMLBytes.length > QueryReply.XML_MAX_SIZE) && (currResps.length > 1))       splitAndAddResponses(splitResps,currResps);
 else {
        byte[] xmlCompressed=null;
        if ((currXML != null) && (!currXML.equals("String_Node_Str")))         xmlCompressed=LimeXMLUtils.compress(currXMLBytes);
 else         xmlCompressed=DataUtils.EMPTY_BYTE_ARRAY;
        queryReply=new QueryReply(guid,ttl,port,ip,speed,currResps,_clientGUID,xmlCompressed,notIncoming,busy,uploaded,measuredSpeed,ChatSettings.CHAT_ENABLED.getValue(),isFromMcast,canFWTransfer,proxies);
        queryReplies.add(queryReply);
      }
    }
  }
 else {
    byte[] xmlCompressed=null;
    if (xmlCollectionString != null && !xmlCollectionString.equals("String_Node_Str"))     xmlCompressed=LimeXMLUtils.compress(xmlBytes);
 else     xmlCompressed=DataUtils.EMPTY_BYTE_ARRAY;
    queryReply=new QueryReply(guid,ttl,port,ip,speed,res,_clientGUID,xmlCompressed,notIncoming,busy,uploaded,measuredSpeed,ChatSettings.CHAT_ENABLED.getValue(),isFromMcast,canFWTransfer,proxies);
    queryReplies.add(queryReply);
  }
  return queryReplies;
}