if (MessageUtils.getToAgent(msg).equals(oldToAgent) &&
if (msg != null && MessageUtils.getToAgent(msg).equals(oldToAgent) &&
  void handleMessagesToRestartedAgent(AgentID fromAgent, AgentID oldToAgent, AgentID newToAgent)       throws org.cougaar.core.mts.NameLookupException, org.cougaar.core.mts.CommFailureException  {    if (debug())       log.debug("MessageResender: enter dequeueMessages("+fromAgent+","+oldToAgent+","+newToAgent+")");    synchronized(queue) {      MessageAddress originator = MessageAddress.getMessageAddress(fromAgent.getAgentName());      AgentState agentState = aspect.getAgentState(originator);      if (agentState != null) {        synchronized (agentState) {          Vector msgs = (Vector)agentState.getAttribute(MessageAckingAspect.SENT_BUT_NOT_ACKED_MSGS);          if (msgs != null) {             // sort them by msg num            Collections.sort(msgs, MsgNumSort.getInstance());            Iterator i = msgs.iterator();            while (i.hasNext()) {              AttributedMessage msg = (AttributedMessage)i.next();              if (MessageUtils.getToAgent(msg).equals(oldToAgent) &&                   !aspect.hasMessageBeenAcked(msg)) {		// change AgentID and renumber messages                MessageUtils.setToAgent(msg, newToAgent);                if (messageNumberingService == null) {                  ServiceBroker sb = aspect.getServiceBroker();                  messageNumberingService =                     (MessageNumberingService)sb.getService(this, MessageNumberingService.class, null);                }                messageNumberingService.renumberMessage(msg);                if (debug())                   log.debug("MessageResender: dequeued msg: " +MessageUtils.toString(msg));              }            }            offerNewResendDeadline(0);          }        }      }    }    if (debug())       log.debug("MessageResender: exit dequeueMessages("+fromAgent+","+oldToAgent+","+newToAgent+")");  }