File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 4444 */
4545public class QueueingConsumer extends DefaultConsumer {
4646 private final BlockingQueue <Delivery > _queue ;
47+
48+ // When this is non-null the queue is in shutdown mode and nextDelivery should
49+ // throw a shutdown signal exception.
4750 private volatile ShutdownSignalException _shutdown ;
4851
4952 // Marker object used to signal the queue is in shutdown mode.
53+ // It is only there to wake up consumers. The canonical representation
54+ // of shutting down is the presence of _shutdown.
5055 // Invariant: This is never on _queue unless _shutdown != null.
5156 private static final Delivery POISON = new Delivery (null , null , null );
5257
@@ -113,10 +118,18 @@ public byte[] getBody() {
113118 }
114119 }
115120
121+ /**
122+ * Check if we are in shutdown mode and if so throw an exception.
123+ */
116124 private void checkShutdown (){
117- if (_shutdown != null ) throw _shutdown ;
125+ if (_shutdown != null ) throw Utility . fixStackTrace ( _shutdown ) ;
118126 }
119127
128+ /**
129+ * If this is a non-POISON non-null delivery simply return it.
130+ * If this is POISON we are in shutdown mode, throw _shutdown
131+ * If this is null, we may be in shutdown mode. Check and see.
132+ */
120133 private Delivery handle (Delivery delivery )
121134 {
122135 if (delivery == POISON || (delivery == null && _shutdown != null )){
You can’t perform that action at this time.
0 commit comments