activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nigel Tamplin (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AMQ-3369) occasionally NPE in ActiveMQTextMessage.getSize()
Date Mon, 22 Aug 2011 13:19:29 GMT

    [ https://issues.apache.org/jira/browse/AMQ-3369?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13088678#comment-13088678
] 

Nigel Tamplin commented on AMQ-3369:
------------------------------------

I was also seeing this error in a high load system with embedded AMQ,  but was unable to reproduce
in a small / simple test case.

The exception was originating from a single thread with a transacted session, running in a
bigger application (a subtle timing issue?).
The thread was creating TextMessages from external events, sending to a queue then committing
the session, shortly after the same thread would read back from that queue and send to another
queue then commit again.
It was the send to the 2nd queue that would very occasionally throw the NullPointer.  In 30
– 40 thousand iterations over a 12 hour period I'd see the NullPointer maybe 20 times. 
I could not however contrive a test case to reliably reproduce it.

What I could do however was to put the JVM in debug mode and catch the NullPointer.

What I found was

public int getSize() {
        if (size  0 && content  null && text != null) {
            size = getMinimumMessageSize();
            if (marshalledProperties != null) {
                size += marshalledProperties.getLength();
            }
            size = text.length() * 2;        <<<< null pointer thrown here
        }
        return super.getSize();
    }

Exception occurred: java.lang.NullPointerException (to be caught at: org.apache.activemq.ActiveMQSession.send(),
line=1,700 bci=447)"thread=Thread 50", org.apache.activemq.command.ActiveMQTextMessage.getSize(),
line=148 bci=57
148                size = text.length() * 2;

MQ IN SMA.TEST.ORBITAL.01.CT/MQ_LOOP_BACK.1[1] list
144                size = getMinimumMessageSize();
145                if (marshalledProperties != null) {
146                    size += marshalledProperties.getLength();
147                }
148 =>             size = text.length() * 2;
149            }
150            return super.getSize();
151        }
152        
153        public String toString() {
Thread 50[1] print text
 text = null

Since the check that text != null and the accessing of text it was being set to null.

I was running version 5.3.0, and suspected the cause of the NullPointer to be the
	text = null;
assignment at the end of the beforeMarshall() method in ActiveMQTextMessage.  This looks to
be the only place it could be set to null.

See 
https://issues.apache.org/jira/browse/AMQ-2103
https://issues.apache.org/jira/browse/AMQ-2966

The “text = null;” assignment is present in AMQ versions 5.3.0, 5.3.1, 5.3.2, 5.4.0, 5.4.1
and removed in 5.4.2 and subsequence versions.

Unable to upgrade to 5.4.2 (or newer) in the short term, but needing to avoid this problem
immediately I rebuilt 5.3.0 removing the “text=null;” assignment and have not experienced
the NullPointerException since.

> occasionally NPE in ActiveMQTextMessage.getSize()
> -------------------------------------------------
>
>                 Key: AMQ-3369
>                 URL: https://issues.apache.org/jira/browse/AMQ-3369
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: Broker
>    Affects Versions: 5.4.1
>         Environment: JDK 1.6 (64-bit), Windows Server 2008 x64
>            Reporter: Ivan Pechorin
>
> Sometime we get NullPointerException when sending a text message. We use method send(destination,
message) of interface javax.jms.MessageProducer.
> java.lang.NullPointerException
>  at org.apache.activemq.command.ActiveMQTextMessage.getSize(ActiveMQTextMessage.java:148)
>  at org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1753)
>  at org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:231)
>  at org.apache.activemq.ActiveMQMessageProducerSupport.send(ActiveMQMessageProducerSupport.java:300)
> Caller code is:
> try {
>     final TextMessage message = session.createTextMessage(msg);
>     message.setJMSType(type);
>     message.setJMSReplyTo(destination);
>     message.setJMSCorrelationID(jmsMessageId);
>     producer.send(destination, message);
> } catch (JMSException ex) {
>     ...
> }
> I.e. we don't reuse or store the message being sent.
> We are also 100% sure that both session and its producer are used only from one thread
at any point of time (we have custom session pool).
> Broker URI is vm://jboss-activemq-broker?jms.copyMessageOnSend=false&jms.objectMessageSerializationDefered=true&jms.useAsyncSend=true
> The NPE occurs occasionally, we were not able to reproduce it deterministically so far.
> Any suggestions on how to investigate this?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

Mime
View raw message