Program: 128316
Project: 128316
Buggy source:
/** 
 * DOC sort the outgoingconnections to make sure the first connection is EConnectionType.FLOW_MAIN or EConnectionType.FLOW_REF<br/> <p> bug:9363, if a component have 2 output links, <li>"EConnectionType.FLOW_MAIN(FLOW), EConnectionType.FLOW_REF(REJECT)"</li> <li>"EConnectionType.FLOW_MAIN(REJECT), EConnectionType.FLOW_REF(FLOW)"</li>, make FLOW before "REJECT" </p>
 * @param node
 * @return List<? extends IConnection>
 */
public static List<? extends IConnection> getOutgoingCamelSortedConnections(INode node){
  List<IConnection> conns=null;
  List<? extends IConnection> outgoingConnections=node.getOutgoingConnections();
  if (outgoingConnections != null) {
    conns=new ArrayList<IConnection>(outgoingConnections);
    Collections.sort(conns,new Comparator<IConnection>(){
      public int compare(      IConnection o1,      IConnection o2){
        if (EConnectionType.ROUTE_WHEN == o1.getLineStyle()) {
          if (EConnectionType.ROUTE == o2.getLineStyle()) {
            return 1;
          }
          return -1;
        }
        if (EConnectionType.ROUTE_OTHER == o1.getLineStyle())         if (EConnectionType.ROUTE_WHEN == o2.getLineStyle())         return 1;
        if (EConnectionType.ROUTE_ENDBLOCK == o1.getLineStyle()) {
          if (EConnectionType.ROUTE_WHEN == o2.getLineStyle() || EConnectionType.ROUTE_OTHER == o2.getLineStyle())           return 2;
          if (EConnectionType.ROUTE_TRY == o2.getLineStyle() || EConnectionType.ROUTE_CATCH == o2.getLineStyle() || EConnectionType.ROUTE_FINALLY == o2.getLineStyle())           return 3;
          if (EConnectionType.ROUTE == o2.getLineStyle()) {
            return 4;
          }
        }
        if (EConnectionType.ROUTE_TRY == o1.getLineStyle())         return -1;
        if (EConnectionType.ROUTE_CATCH == o1.getLineStyle())         if (EConnectionType.ROUTE_TRY == o2.getLineStyle())         return 1;
        if (EConnectionType.ROUTE_FINALLY == o1.getLineStyle())         if (EConnectionType.ROUTE_TRY == o2.getLineStyle() || EConnectionType.ROUTE_CATCH == o2.getLineStyle())         return 2;
        return 0;
      }
    }
);
  }
  return conns;
}

Fixed version (ground truth):
/** 
 * DOC sort the outgoingconnections to make sure the first connection is EConnectionType.FLOW_MAIN or EConnectionType.FLOW_REF<br/> <p> bug:9363, if a component have 2 output links, <li>"EConnectionType.FLOW_MAIN(FLOW), EConnectionType.FLOW_REF(REJECT)"</li> <li>"EConnectionType.FLOW_MAIN(REJECT), EConnectionType.FLOW_REF(FLOW)"</li>, make FLOW before "REJECT" </p>
 * @param node
 * @return List<? extends IConnection>
 */
public static List<? extends IConnection> getOutgoingCamelSortedConnections(INode node){
  List<IConnection> conns=null;
  List<? extends IConnection> outgoingConnections=node.getOutgoingConnections();
  if (outgoingConnections != null) {
    conns=new ArrayList<IConnection>(outgoingConnections);
    Collections.sort(conns,new Comparator<IConnection>(){
      @Override public int compare(      IConnection o1,      IConnection o2){
        if (EConnectionType.ROUTE_WHEN == o1.getLineStyle()) {
          if (EConnectionType.ROUTE == o2.getLineStyle()) {
            return 1;
          }
          return -1;
        }
        if (EConnectionType.ROUTE_OTHER == o1.getLineStyle()) {
          if (EConnectionType.ROUTE_WHEN == o2.getLineStyle()) {
            return 1;
          }
        }
        if (EConnectionType.ROUTE_ENDBLOCK == o1.getLineStyle()) {
          if (EConnectionType.ROUTE_WHEN == o2.getLineStyle() || EConnectionType.ROUTE_OTHER == o2.getLineStyle()) {
            return 2;
          }
          if (EConnectionType.ROUTE_TRY == o2.getLineStyle() || EConnectionType.ROUTE_CATCH == o2.getLineStyle() || EConnectionType.ROUTE_FINALLY == o2.getLineStyle()) {
            return 3;
          }
          if (EConnectionType.ROUTE == o2.getLineStyle()) {
            return 4;
          }
        }
        if (EConnectionType.ROUTE_TRY == o1.getLineStyle()) {
          return -1;
        }
        if (EConnectionType.ROUTE_CATCH == o1.getLineStyle()) {
          if (EConnectionType.ROUTE_TRY == o2.getLineStyle()) {
            return 1;
          }
        }
        if (EConnectionType.ROUTE_FINALLY == o1.getLineStyle()) {
          if (EConnectionType.ROUTE_TRY == o2.getLineStyle() || EConnectionType.ROUTE_CATCH == o2.getLineStyle()) {
            return 2;
          }
        }
        return 0;
      }
    }
);
  }
  return conns;
}