Iterator it = sipStack.getRouter().getNextHops(request); if (it == null || !it.hasNext()) throw new SipException("could not determine next hop!");  if (((SIPRequest) request).getTopmostVia() == null) throw new SipException("Invalid SipRequest -- no via header!");     SIPTransaction tr = sipStack.findTransaction((SIPRequest) request, false); if (tr != null) throw new SipException("Cannot send statelessly Transaction found!");
if (!sipStack.isAlive()) throw new SipException("Stack is stopped."); Hop hop = sipStack.getRouter((SIPRequest)request).getNextHop(request); if (hop == null) throw new SipException("could not determine next hop!"); SIPRequest sipRequest = (SIPRequest) request; if (sipRequest.getTopmostVia() == null) throw new SipException("Invalid SipRequest -- no via header!");
    public void sendRequest(Request request) throws SipException {        Iterator it = sipStack.getRouter().getNextHops(request);        if (it == null || !it.hasNext())            throw new SipException("could not determine next hop!");        // Bug reported by Rhys Ulerich        if (((SIPRequest) request).getTopmostVia() == null)            throw new SipException("Invalid SipRequest -- no via header!");        // Will slow down the implementation because it involves        // a search to see if a transaction exists.        // This is a common bug so adding some assertion        // checking under debug.        SIPTransaction tr = sipStack.findTransaction((SIPRequest) request,                false);        if (tr != null)            throw new SipException("Cannot send statelessly Transaction found!");        while (it.hasNext()) {            Hop nextHop = (Hop) it.next();            try {                SIPRequest sipRequest = (SIPRequest) request;                String bid = sipRequest.getTransactionId();                Via via = sipRequest.getTopmostVia();                via.setBranch(bid);                SIPRequest newRequest;                newRequest = sipRequest;                MessageChannel messageChannel = sipStack                        .createRawMessageChannel(this.listeningPoint.port, nextHop);                if (messageChannel != null) {                    messageChannel.sendMessage((SIPMessage) newRequest);		    return;                } else {		    continue;		}            } catch (IOException ex) {		if (LogWriter.needsLogging ) {			sipStack.getLogWriter().logException (ex);		}		continue;            } catch (ParseException ex1) {                InternalErrorHandler.handleException(ex1);            }        }	// Could not find a suitable hop to forward the request.        throw new SipException("could not forward request");    }