glassfish
  1. glassfish
  2. GLASSFISH-12564

Cannot set null string property on Object Message

    Details

    • Type: Bug Bug
    • Status: Reopened
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: v3.0.1
    • Fix Version/s: 4.1
    • Component/s: jms
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

      Description

      glassfish v3.0.1
      sun jdk 1.6.0_20
      windows xp 32bit

      The JMS Message interface javadoc states that null is valid value for a string
      property on a message.

      If you invoke this code in a stateless ejb, you receive the stack trace below

      Connection connection = connectionFactory.createConnection();
      Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
      MessageProducer producer = session.createProducer(destination);
      ObjectMessage message = session.createObjectMessage();
      message.setObject(new Object());
      message.setStringProperty("aStringProperty", null);

      Caused by: java.lang.NullPointerException
      at
      com.sun.messaging.jms.ra.DirectPacket._checkAndSetProperty(DirectPacket.java:157
      9)
      at
      com.sun.messaging.jms.ra.DirectPacket.setStringProperty(DirectPacket.java:1390)

        Issue Links

          Activity

          Hide
          Satish Kumar added a comment -

          Setting target milestone and reassigning this to Nigel ..

          Show
          Satish Kumar added a comment - Setting target milestone and reassigning this to Nigel ..
          Hide
          Nigel Deakin added a comment -

          Updating target milestone to M5 to confirm that this is already fixed.

          Show
          Nigel Deakin added a comment - Updating target milestone to M5 to confirm that this is already fixed.
          Hide
          Nigel Deakin added a comment -

          Oops, ignore previous comment added to the wrong issue in error. Setting target
          milestone back to M7.

          Show
          Nigel Deakin added a comment - Oops, ignore previous comment added to the wrong issue in error. Setting target milestone back to M7.
          Hide
          Nigel Deakin added a comment -

          In GlassFish 3.1 the error is

          SEVERE: Error processing message
          javax.jms.MessageFormatException: [C4040]: Invalid ObjectProperty type for
          property aStringProperty
          at
          com.sun.messaging.jmq.jmsclient.MessageImpl.checkAndSetProperty(MessageImpl.java:818)
          at
          com.sun.messaging.jmq.jmsclient.MessageImpl.setStringProperty(MessageImpl.java:2041)

          Show
          Nigel Deakin added a comment - In GlassFish 3.1 the error is SEVERE: Error processing message javax.jms.MessageFormatException: [C4040] : Invalid ObjectProperty type for property aStringProperty at com.sun.messaging.jmq.jmsclient.MessageImpl.checkAndSetProperty(MessageImpl.java:818) at com.sun.messaging.jmq.jmsclient.MessageImpl.setStringProperty(MessageImpl.java:2041)
          Hide
          Nigel Deakin added a comment -

          (previous stack trace was for LOCAL brokers),

          And in GlassFish 3.1 the stack trace is

          Caused by: java.lang.NullPointerException
          at
          com.sun.messaging.jms.ra.DirectPacket._checkAndSetProperty(DirectPacket.java:1581)
          at
          com.sun.messaging.jms.ra.DirectPacket.setStringProperty(DirectPacket.java:1392)

          which matches what the submitted reported.

          Show
          Nigel Deakin added a comment - (previous stack trace was for LOCAL brokers), And in GlassFish 3.1 the stack trace is Caused by: java.lang.NullPointerException at com.sun.messaging.jms.ra.DirectPacket._checkAndSetProperty(DirectPacket.java:1581) at com.sun.messaging.jms.ra.DirectPacket.setStringProperty(DirectPacket.java:1392) which matches what the submitted reported.
          Hide
          Nigel Deakin added a comment -

          I've read the JMS 1.1 specification and the JavaDoc for javax.jms.Message, and
          have not seen anything which suggests setting a String property can be set to
          null. (Feel free to argue).

          The behaviour when using a LOCAL broker is correct, which is to throw a
          MessageFormatException.

          The behaviour when using a EMBEDDED broker is incorrect. A NullPointerException
          should not be thrown; a MessageFormatException should be thrown instead. I will
          make this change.

          Show
          Nigel Deakin added a comment - I've read the JMS 1.1 specification and the JavaDoc for javax.jms.Message, and have not seen anything which suggests setting a String property can be set to null. (Feel free to argue). The behaviour when using a LOCAL broker is correct, which is to throw a MessageFormatException. The behaviour when using a EMBEDDED broker is incorrect. A NullPointerException should not be thrown; a MessageFormatException should be thrown instead. I will make this change.
          Hide
          Nigel Deakin added a comment -

          The exception that is thrown when an embedded broker is used has been changed to:

          javax.jms.MessageFormatException: MQJMSRA_DM4001:
          setStringProperty():name=aStringProperty:value=null:Bad property value: null

          Show
          Nigel Deakin added a comment - The exception that is thrown when an embedded broker is used has been changed to: javax.jms.MessageFormatException: MQJMSRA_DM4001: setStringProperty():name=aStringProperty:value=null:Bad property value: null
          Hide
          Nigel Deakin added a comment -

          Section 3.12 of the JMS spec "Provider Implementations of JMS Message
          Interfaces" states:

          "The JMS message interfaces provide write/set methods for setting object
          values in a message body and message properties. All of these methods must
          be implemented to copy their input objects into the message. The value of an
          input object is allowed to be null and will return null when accessed."

          Reopening this issue and setting target milestone to M7.

          Show
          Nigel Deakin added a comment - Section 3.12 of the JMS spec "Provider Implementations of JMS Message Interfaces" states: "The JMS message interfaces provide write/set methods for setting object values in a message body and message properties. All of these methods must be implemented to copy their input objects into the message. The value of an input object is allowed to be null and will return null when accessed." Reopening this issue and setting target milestone to M7.
          Hide
          Nigel Deakin added a comment -

          This does seem a valid complaint, though as it's a spec misinterpretation rather
          than a bug, and MQ has almost certainly had this behaviour for many years,
          fixing it can't be considered a priority for 3.1.

          I'm leaving this as a P3 priority, but deferring it until 3.2 (MQ 4.6).

          Show
          Nigel Deakin added a comment - This does seem a valid complaint, though as it's a spec misinterpretation rather than a bug, and MQ has almost certainly had this behaviour for many years, fixing it can't be considered a priority for 3.1. I'm leaving this as a P3 priority, but deferring it until 3.2 (MQ 4.6).
          Hide
          vladchuk added a comment -

          Why is this not being addressed in 3.1.2? It seems that 3.2 has been abandoned (superseded by 4.0) and 4.0 is far away.
          Please consider fixing it in 3.1.2.

          Show
          vladchuk added a comment - Why is this not being addressed in 3.1.2? It seems that 3.2 has been abandoned (superseded by 4.0) and 4.0 is far away. Please consider fixing it in 3.1.2.
          Hide
          exabrial added a comment -

          any chance this could be fixed in 3.1.2? I can't imagine this is a difficult fix.

          Show
          exabrial added a comment - any chance this could be fixed in 3.1.2? I can't imagine this is a difficult fix.
          Hide
          Nigel Deakin added a comment -

          I've logged MQ-165 and made this issue dependent on it.

          Show
          Nigel Deakin added a comment - I've logged MQ-165 and made this issue dependent on it.
          Hide
          Nigel Deakin added a comment -

          In accordance with the project triage guidelines this is not needed for 4.0 and so has been deferred until 4.0.1. Setting "fix version" accordingly.

          Show
          Nigel Deakin added a comment - In accordance with the project triage guidelines this is not needed for 4.0 and so has been deferred until 4.0.1. Setting "fix version" accordingly.

            People

            • Assignee:
              Nigel Deakin
              Reporter:
              exabrial
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: