}  if (d != null) { ref.incrementDeliveryCount(); }
}
   private Delivery getDelivery(Receiver receiver, MessageReference ref)   {            Delivery d = null;                  if (receiver == null)      {         Set deliveries = router.handle(this, ref, null);                  if (deliveries.isEmpty())         {            return null;         }                  //Sanity check - we shouldn't get more then one delivery -          //the Channel can only cope with one delivery per message reference         //at any one time.         //Eventually this will be enforced in the design of the core classes         //but for now we just throw an Exception         if (deliveries.size() > 1)         {            throw new IllegalStateException("More than one delivery returned from router!");         }                  d = (Delivery)deliveries.iterator().next();      }      else      {         try         {            d = receiver.handle(this, ref, null);               if (d != null && d.isCancelled())            {               d = null;                           }            }         catch(Throwable t)         {            // broken receiver - log the exception and ignore it            log.error("The receiver " + receiver + " is broken", t);         }      }            if (d != null)      {         ref.incrementDeliveryCount();      }            return d;   }