mq
  1. mq
  2. MQ-335

readBytes(byte[] value) in StreamMessage class throws NullPointerException instead of JMSException

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Glassfish 4.0.1 b02 02/07/2013
      Windows

      Description

      When null is specified for readBytes(bytes[] value) in StreamMessage class, NullPointerException is thrown. It should throw JMSException.

      Manual is here.
      https://mq.java.net/javadoc/4.5/javadoc/javax/jms/StreamMessage.html#readBytes%28byte[]%29

        Activity

        Hide
        tak09 added a comment -

        Similar problems:

        NullPointerException is thrown when null byte[] is specified for StreamMessage.writeBytes(byte[] value, int offset, int length).

        NullPointerException when is thrown null byte[] is specified for MapMessage.setBytes(String name, byte[] value, int offset, int length).

        Show
        tak09 added a comment - Similar problems: NullPointerException is thrown when null byte[] is specified for StreamMessage.writeBytes(byte[] value, int offset, int length). NullPointerException when is thrown null byte[] is specified for MapMessage.setBytes(String name, byte[] value, int offset, int length).
        Hide
        Nigel Deakin added a comment -

        The JMS spec doesn't define what should happen in this case (though it is clearly invalid and an exception of some kind should result). Throwing a JMSException would probably be valid, but throwing a more specific unchecked exception such as a {{NullPointerException }} would be valid too, in my opinion.

        As a general policy, I don't think the existence of JMSException should force the provider to catch every possible unchecked exception (e.g. java.lang.OutOfMemoryError) and wrap it in a JMSException. The only cases where a JMSException must be thrown are in the cases listed in the API documentation.

        Show
        Nigel Deakin added a comment - The JMS spec doesn't define what should happen in this case (though it is clearly invalid and an exception of some kind should result). Throwing a JMSException would probably be valid, but throwing a more specific unchecked exception such as a {{NullPointerException }} would be valid too, in my opinion. As a general policy, I don't think the existence of JMSException should force the provider to catch every possible unchecked exception (e.g. java.lang.OutOfMemoryError ) and wrap it in a JMSException . The only cases where a JMSException must be thrown are in the cases listed in the API documentation.

          People

          • Assignee:
            Ed Bratt
            Reporter:
            tak09
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: