[ 
https://issues.apache.org/jira/browse/QPID-1374?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12640961#action_12640961
 ] 

Arnaud Simon commented on QPID-1374:
------------------------------------

Revision: 706166
Modified:
    
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessageFactory.java
    
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/MessageFactoryRegistry.java

Modified: 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessageFactory.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessageFactory.java?rev=706166&r1=706165&r2=706166&view=diff
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessageFactory.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessageFactory.java
 Mon Oct 20 02:36:38 2008
@@ -131,8 +131,18 @@
                     .remaining());
         }
         // set the properties of this message
-        MessageProperties mprop = (MessageProperties) contentHeader[0];
-        DeliveryProperties devprop = (DeliveryProperties) contentHeader[1];
+        MessageProperties mprop;
+        DeliveryProperties devprop;
+        if( contentHeader.length >1 )
+        {
+          mprop = (MessageProperties) contentHeader[0];
+          devprop = (DeliveryProperties) contentHeader[1];
+        }
+        else
+        {
+          mprop = new MessageProperties();
+          devprop = (DeliveryProperties) contentHeader[0];
+        }
 
         AMQMessageDelegate delegate = new AMQMessageDelegate_0_10(mprop, 
devprop, messageNbr);
 

Modified: 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/MessageFactoryRegistry.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/MessageFactoryRegistry.java?rev=706166&r1=706165&r2=706166&view=diff
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/MessageFactoryRegistry.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/MessageFactoryRegistry.java
 Mon Oct 20 02:36:38 2008
@@ -125,12 +125,16 @@
     {
 
         MessageProperties mprop = 
transfer.getHeader().get(MessageProperties.class);
-        String messageType = mprop.getContentType();
-        if (messageType == null)
+        String messageType = "";
+        if ( mprop == null || mprop.getContentType() == null)
         {
             _logger.debug("no message type specified, building a byte 
message");
             messageType = JMSBytesMessage.MIME_TYPE;
         }
+        else
+        {
+           messageType = mprop.getContentType();
+        }
         MessageFactory mf = _mimeStringToFactoryMap.get(messageType);
         if (mf == null)
         {

> Java client throws NullPointerException  when header " message properties"  
> is not set 
> ---------------------------------------------------------------------------------------
>
>                 Key: QPID-1374
>                 URL: https://issues.apache.org/jira/browse/QPID-1374
>             Project: Qpid
>          Issue Type: Bug
>          Components: Java Client
>    Affects Versions: M4
>            Reporter: Arnaud Simon
>            Assignee: Arnaud Simon
>             Fix For: M4
>
>
> The java JMS layer expects that all messages have message properties set. 
> This is however not always  the case as AMQP doesn't mandate the message 
> properties header to always be set. For example the python client doesn't set 
> the message properties when they are empty. 
> How to reproduce: 
> - Send messages using the python client 
> - Consume those messages with a java consumer
> Solution: 
> update AbstractJMSMessageFactory and MessageFactoryRegistry for dealing with 
> null message properties header  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to