If a read method of a BytesMessage throws a MessageFormatException or NumberFormatException, the current position of the read pointer must not be incremented. A subsequent read must be capable of recovering from the exception by re-reading the data as a different type.
NOTE: With the exception of the readUTF() method, it is difficult to conceive test cases for read methods.

  • A provider that implements BytesMessage using a DataInputStream or equivalent, is likely to only throw MessageFormatException for the readUTF() method.
    The other likely exceptions are MessageEOFException for stream overruns, and JMSException for any other error.
  • As BytesMessage does not support conversion, NumberFormatException is unlikely to be thrown.


  • Section 3.11.3, Conversions Provided by StreamMessage and MapMessage