mq
  1. mq
  2. MQ-330

JMSException is not caused when invalid argument is set for MapMessage class setBytes method

    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-07_24_2013
      Windows

      Description

      When invalid values are set for setBytes method of MapMessage, JMSException is not caused.

      void setBytes(String name,byte[] value,int offset,int length)

      • When -1 is specified for length, NagativeArraySizeException is caused.
      • ArrayIndexOutOfBoundsException is caused when value < length.

      I found a same bug in writeBytes method in StreamMessage as well.

      void writeBytes(byte[] value, int offset, int length)

        Activity

        Hide
        tak09 added a comment -
        Show
        tak09 added a comment - https://www.dropbox.com/sh/jk2re1abamtmg37/vwJQ6DQwfv Test program.
        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 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, which relate to using an inappropriate method to read data from the byte array.

        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 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, which relate to using an inappropriate method to read data from the byte array.

          People

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

            Dates

            • Created:
              Updated: