@ Override public void reset ( ) throws JMSException { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . entry ( this , tc , "reset" ) ; // After reset has been called, the message body is immutable (the only way of changing it is to // call clearBody and start again). If we're in Write Mode, we need to convert the writeStream // to a byte array and switch into read mode. If we're in Read Mode, we must have already done this, // so we don't want to do it again if ( ! isBodyReadOnly ( ) ) { // If the producer won't modify the payload after set,skip the // encoding of the write stream because encoding is not needed if ( ! producerWontModifyPayloadAfterSet ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) SibTr . debug ( this , tc , "Body is writeable & producer might modify the payload, so encode the write stream" ) ; // Convert the stream in which the message was being assembled to a byte array dataBuffer = _writeBytes . toByteArray ( ) ; // store the content in the JS msg lastEncoding = integerEncoding | floatEncoding ; jsBytesMsg . setBytes ( _exportBody ( lastEncoding ) ) ; bodySetInJsMsg = true ; // Throw away the write stream writeStream = null ; _writeBytes = null ; } dataStart = 0 ; // start from the first byte in the buffer // The message is now read only setBodyReadOnly ( ) ; } // For some odd reason, after receiving an 'empty' message the dataBuffer // is null rather than pointing to an empty array. This will compensate // hopefully without any side effects - SXA #58832 if ( dataBuffer == null ) dataBuffer = new byte [ 0 ] ; // Create a Byte array input stream for the readxxx methods to operate on. We have to create a new // stream each time (rather than call the stream's read method), as the stream may have a position // marked in it that isn't at the start. _readBytes = new ByteArrayInputStream ( dataBuffer ) ; readStream = new DataInputStream ( _readBytes ) ; // Jump over any header that might be present in the dataBuffer // JBK - I don't think we will ever have dataStart!=0 in JS, but I'm // leaving the capability here until I understand better. try { readStream . skip ( dataStart ) ; } catch ( IOException e ) { } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) SibTr . exit ( this , tc , "reset" ) ; }
Put the message in read - only mode and reposition the stream of bytes to the beginning .