[
https://issues.apache.org/jira/browse/AMQ-6425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17107201#comment-17107201
]
Dave Cree commented on AMQ-6425:
--------------------------------
We have also encountered this issue with version 5.14.1 in a CentOS 7.4,
jdk1.8.0_92 environment.
The important bits in the stack trace in the exception are these:
{noformat}
at
org.apache.activemq.web.MessageServlet.handleContinuation(MessageServlet.java:282)
at
org.apache.activemq.web.MessageServlet.doMessages(MessageServlet.java:238)
at org.apache.activemq.web.MessageServlet.doGet(MessageServlet.java:172)
{noformat}
In the handleContinuation method, the exception is being encountered in the
last line of this block:
{noformat}
synchronized (consumer) {
Listener listener = (Listener) consumer.getAvailableListener();
// register this continuation with our listener.
listener.setContinuation(continuation);
}
{noformat}
i.e. the available listener that is obtained from the consumer is null.
The handleContinuation method is called from the doMessages method, if no
message is received from the consumer:
{noformat}
// Look for any available messages (need a little timeout). Always
// try at least one lookup; don't block past the deadline.
if (timeout <= 0) {
message = consumer.receiveNoWait();
} else if (timeout < 10) {
message = consumer.receive(timeout);
} else {
message = consumer.receive(10);
}
if (message == null) {
handleContinuation(request, response, client, destination,
consumer, deadline);
} else {
writeResponse(request, response, message);
closeConsumerOnOneShot(request, client, destination);
synchronized (activeConsumers) {
activeConsumers.remove(consumer);
}
}
{noformat}
Just prior to that, in the doMessages method, the available listener is set for
the consumer (if there isn't one already):
{noformat}
synchronized (consumer) {
Listener listener = (Listener) consumer.getAvailableListener();
if (listener == null) {
listener = new Listener(consumer);
consumer.setAvailableListener(listener);
}
}
{noformat}
Therefore, the available listener for the consumer must be getting set to null
sometime between it being set in the consumer in the doMessages method and the
attempt to get it from the consumer in the handleContinuation method.
In the internal Listener class of the MessageServlet class the
onMessageAvailable method sets the available listener for the consumer to null:
{noformat}
@Override
public void onMessageAvailable(MessageConsumer consumer) {
assert this.consumer == consumer;
((MessageAvailableConsumer) consumer).setAvailableListener(null);
synchronized (this.consumer) {
if (continuation != null) {
continuation.resume();
}
}
}
{noformat}
This could possibly be a race condition where one thread, in the doMessages
method, attempts to get a message but it is not available yet and so calls the
handleContinuation method. Then the message becomes available and a second
thread has the onMessageAvailable method called (setting the available listener
for the consumer to null) before the first thread tries to get the available
listener from the consumer.
> Communication over REST: java.lang.NullPointerException in
> MessageServlet.java:282
> ----------------------------------------------------------------------------------
>
> Key: AMQ-6425
> URL: https://issues.apache.org/jira/browse/AMQ-6425
> Project: ActiveMQ
> Issue Type: Bug
> Affects Versions: 5.11.4, 5.13.3, 5.14.0
> Environment: Windows 7, JDK jdk1.8.0_45
> Reporter: pa ko
> Priority: Major
> Attachments: Active MQ communication problem.docx, amq.war
>
>
> --for more details see attached word file / amq.war --
> the REST client gets messages from the ActiveMQ server continously, after
> some time the ActiveMQ server crashed (NullPointerException)
> After this exception the communication doesn't work anymore (blocked)
--
This message was sent by Atlassian Jira
(v8.3.4#803005)