if (trace) { log.trace("message " + m + " is not expired, returning it to the caller"); }
if (trace) { log.trace("message " + m + " is not expired, pushing it to the caller"); }
   public MessageProxy receive(long timeout) throws JMSException   {                          synchronized (mainLock)      {                  if (closed)         {            throw new JMSException("Cannot call receive(..) Consumer is closed");         }                  if (listener != null)         {            throw new JMSException("The consumer has a MessageListener set, cannot call receive(..)");                  }                                receiverThread = Thread.currentThread();                        long startTimestamp = System.currentTimeMillis();                  MessageProxy m = null;                  try         {            while(true)            {                                            if (timeout == 0)               {                  if (trace) { log.trace("receive with no timeout"); }                                    m = getMessage(0);                                                         if (m == null)                  {                     return null;                  }               }               else if (timeout == -1)               {                  //ReceiveNoWait                  if (trace) { log.trace("receive noWait"); }                                                      m = getMessage(-1);                                                         if (m == null)                  {                     if (trace) { log.trace("no message available"); }                     return null;                  }               }               else               {                  if (trace) { log.trace("receive timeout " + timeout + " ms, blocking poll on queue"); }                                    m = getMessage(timeout);                                                      if (m == null)                  {                     // timeout expired                     if (trace) { log.trace(timeout + " ms timeout expired"); }                                          return null;                  }               }                                             if (trace) { log.trace("received " + m + " after being blocked on the buffer"); }                                                 if (!m.getMessage().isExpired())               {                  if (trace) { log.trace("message " + m + " is not expired, returning it to the caller"); }                                    preDeliver(sessionDelegate, consumerID, m, isConnectionConsumer);                                    postDeliver(sessionDelegate, consumerID, m, isConnectionConsumer);                                    return m;               }                              log.debug("message expired, discarding");                              // the message expired, so discard the message, adjust timeout and reenter the buffer               if (timeout != 0)               {                  timeout -= System.currentTimeMillis() - startTimestamp;               }                              if (closing)               {                  return null;               }                           }         }         finally         {            receiverThread = null;                     }      }    }    