ref.decrementChannelCount();
addToDownCache(ref);
   public void cancelDelivery(Delivery del) throws Throwable   {      if (trace) { log.trace(this + " cancelling " + del + " in memory"); }            synchronized (deliveryLock)      {                  boolean removed = deliveries.remove(del);                  if (!removed)         {            //This is ok            //This can happen if the message is cancelled before the result of ServerConsumerDelegate.handle            //has returned, in which case we won't have a record of the delivery in the Set                        //In this case we don't want to add the message reference back into the state            //since it was never removed in the first place                        if (trace) { log.trace(this + " can't find delivery " + del + " in state so not replacing messsage ref"); }         }         else         {                     synchronized (refLock)            {               messageRefs.addFirst(del.getReference(), del.getReference().getPriority());                                          if (trace) { log.trace(this + " added " + del.getReference() + " back into state"); }                              if (paging)               {                  //if paging we need to evict the end reference to storage to preserve the number of refs in the queue                                                   MessageReference ref = (MessageReference)messageRefs.removeLast();                                    ref.decrementChannelCount();                                    if (!ref.isReliable())                  {                     if (downCacheSize > 0)                     {                        addToDownCache(ref);                     }                     else                     {                                             pm.addReference(channel.getChannelID(), ref, null);                      }                     }                             }            }         }      }   }