Buggy code:
@ SuppressWarnings ( "static-access" ) public class JmsSession implements QueueSession , Session , TopicSession , JmsMessageDispatcher { private final JmsConnection connection ; private final int acknowledgementMode ; private final List < JmsMessageProducer > producers = new CopyOnWriteArrayList < JmsMessageProducer > ( ) ; private final Map < JmsConsumerId , JmsMessageConsumer > consumers = new ConcurrentHashMap < JmsConsumerId , JmsMessageConsumer > ( ) ; private MessageListener messageListener ; private final AtomicBoolean closed = new AtomicBoolean ( ) ; private final AtomicBoolean started = new AtomicBoolean ( ) ; private final LinkedBlockingQueue < JmsInboundMessageDispatch > stoppedMessages = new LinkedBlockingQueue < JmsInboundMessageDispatch > ( 10000 ) ; private JmsPrefetchPolicy prefetchPolicy ; private JmsSessionInfo sessionInfo ; private ExecutorService executor ; private final ReentrantLock sendLock = new ReentrantLock ( ) ; private final AtomicLong consumerIdGenerator = new AtomicLong ( ) ; private final AtomicLong producerIdGenerator = new AtomicLong ( ) ; private JmsTransactionContext transactionContext ; private boolean sessionRecovered ; protected JmsSession ( JmsConnection connection , JmsSessionId sessionId , int acknowledgementMode ) throws JMSException { } int acknowledgementMode ( ) { } @ Override public int getAcknowledgeMode ( ) throws JMSException { } @ Override public boolean getTransacted ( ) throws JMSException { } @ Override public MessageListener getMessageListener ( ) throws JMSException { } @ Override public void setMessageListener ( MessageListener listener ) throws JMSException { } @ Override public void recover ( ) throws JMSException { } @ Override public void commit ( ) throws JMSException { } @ Override public void rollback ( ) throws JMSException { } @ Override public void run ( ) { } @ Override public void close ( ) throws JMSException { } protected void doClose ( ) throws JMSException { } protected void shutdown ( ) throws JMSException { } @ Override public MessageConsumer createConsumer ( Destination destination ) throws JMSException { } @ Override public MessageConsumer createConsumer ( Destination destination , String messageSelector ) throws JMSException { } @ Override public MessageConsumer createConsumer ( Destination destination , String messageSelector , boolean noLocal ) throws JMSException { } @ Override public QueueReceiver createReceiver ( Queue queue ) throws JMSException { checkClosed ( ) ; JmsSession . checkDestination ( queue ) ; JmsDestination dest = JmsMessageTransformation . transformDestination ( connection , queue ) ; <START_BUG> JmsQueueReceiver result = new JmsQueueReceiver ( getNextConsumerId ( ) , this , dest , "" ) ; <END_BUG> result . init ( ) ; return result ; } @ Override public QueueReceiver createReceiver ( Queue queue , String messageSelector ) throws JMSException { } @ Override public QueueBrowser createBrowser ( Queue destination ) throws JMSException { } @ Override public QueueBrowser createBrowser ( Queue destination , String messageSelector ) throws JMSException { } @ Override public TopicSubscriber createSubscriber ( Topic topic ) throws JMSException { } @ Override public TopicSubscriber createSubscriber ( Topic topic , String messageSelector , boolean noLocal ) throws JMSException { } @ Override public TopicSubscriber createDurableSubscriber ( Topic topic , String name ) throws JMSException { } @ Override public TopicSubscriber createDurableSubscriber ( Topic topic , String name , String messageSelector , boolean noLocal ) throws JMSException { } protected void checkClientIDWasSetExplicitly ( ) throws IllegalStateException { } @ Override public void unsubscribe ( String name ) throws JMSException { } @ Override public MessageProducer createProducer ( Destination destination ) throws JMSException { } @ Override public QueueSender createSender ( Queue queue ) throws JMSException { } @ Override public TopicPublisher createPublisher ( Topic topic ) throws JMSException { } @ Override public BytesMessage createBytesMessage ( ) throws JMSException { } @ Override public MapMessage createMapMessage ( ) throws JMSException { } @ Override public Message createMessage ( ) throws JMSException { } @ Override public ObjectMessage createObjectMessage ( ) throws JMSException { } @ Override public ObjectMessage createObjectMessage ( Serializable object ) throws JMSException { } @ Override public StreamMessage createStreamMessage ( ) throws JMSException { } @ Override public TextMessage createTextMessage ( ) throws JMSException { } @ Override public TextMessage createTextMessage ( String text ) throws JMSException { } @ Override public Queue createQueue ( String queueName ) throws JMSException { } @ Override public Topic createTopic ( String topicName ) throws JMSException { } @ Override public TemporaryQueue createTemporaryQueue ( ) throws JMSException { } @ Override public TemporaryTopic createTemporaryTopic ( ) throws JMSException { } protected void add ( JmsMessageConsumer consumer ) throws JMSException { } protected void remove ( JmsMessageConsumer consumer ) throws JMSException { } protected void add ( JmsMessageProducer producer ) { } protected void remove ( MessageProducer producer ) { } protected void onException ( Exception ex ) { } protected void onException ( JMSException ex ) { } protected void send ( JmsMessageProducer producer , Destination dest , Message msg , int deliveryMode , int priority , long timeToLive , boolean disableMsgId , boolean disableTimestamp ) throws JMSException { } private void send ( JmsMessageProducer producer , JmsDestination destination , Message original , int deliveryMode , int priority , long timeToLive , boolean disableMsgId , boolean disableTimestamp ) throws JMSException { } void acknowledge ( JmsInboundMessageDispatch envelope , ACK_TYPE ackType ) throws JMSException { } void acknowledge ( ) throws JMSException { } public boolean isClosed ( ) { } public boolean isTransacted ( ) { } protected boolean isClientAcknowledge ( ) { } public boolean isAutoAcknowledge ( ) { } public boolean isDupsOkAcknowledge ( ) { } protected void checkClosed ( ) throws IllegalStateException { } static class OptionalSectorParser { public static void check ( String selector ) throws InvalidSelectorException { } } static final JmsSession . OptionalSectorParser SELECTOR_PARSER ; public static String checkSelector ( String selector ) throws InvalidSelectorException { } public static void checkDestination ( Destination dest ) throws InvalidDestinationException { } protected void start ( ) throws JMSException { } protected void stop ( ) throws JMSException { } protected boolean isStarted ( ) { } public JmsConnection getConnection ( ) { } Executor getExecutor ( ) { }

Fix:
JmsQueueReceiver result = new JmsQueueReceiver ( getNextConsumerId ( ) , this , dest , null ) ;