if (log.isTraceEnabled()) { log.trace("Thread was interrupted"); }
if (trace) { log.trace("Thread was interrupted"); }
   public Message receive(long timeout) throws JMSException   {                             if (listener != null)      {         throw new JBossJMSException("A message listener is already registered");               }                          receiverThread = Thread.currentThread();                  long startTimestamp = System.currentTimeMillis();            Message m = null;            try      {         while(true)         {            try            {               if (timeout == 0)               {                  if (log.isTraceEnabled()) log.trace("receive with no timeout");                                    if (!stopping)                  {                     m = getMessage(0);                  }                                    if (m == null)                  {                     return null;                  }                                    if (log.isTraceEnabled()) { log.trace("got " + m); }               }               else if (timeout == -1)               {                  //ReceiveNoWait                  if (log.isTraceEnabled()) { log.trace("receive noWait"); }                                                      if (!stopping)                  {                     m = getMessage(-1);                  }                                    if (m == null)                  {                     if (log.isTraceEnabled()) { log.trace("no message available"); }                     return null;                  }               }               else               {                  if (log.isTraceEnabled()) { log.trace("receive timeout " + timeout + " ms, blocking poll on queue"); }                                    if (!stopping)                  {                     m = getMessage(timeout);                  }                                    if (m == null)                  {                     // timeout expired                     if (log.isTraceEnabled()) { log.trace(timeout + " ms timeout expired"); }                                          return null;                  }               }            }            catch(InterruptedException e)            {               if (log.isTraceEnabled()) { log.trace("Thread was interrupted"); }                              if (closed)               {                  return null;               }               else               {                  throw new JMSException("Interrupted");               }            }                        if (log.isTraceEnabled()) { log.trace("got " + m); }                                           if (!((MessageDelegate)m).getMessage().isExpired())            {               if (log.isTraceEnabled()) { 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");                        // discard the message, adjust timeout and reenter the buffer            if (timeout != 0)            {               timeout -= System.currentTimeMillis() - startTimestamp;            }         }      }      finally      {         receiverThread = null;               }    }