/** * Block until you can read a message. Returns null if the message was a message chunk. * * @return the message, or null if we only received a chunk of the message */ DistributionMessage readMessage(Header header) throws IOException, ClassNotFoundException { ByteBuffer nioInputBuffer = readAtLeast(header.messageLength); Assert.assertTrue(nioInputBuffer.remaining() >= header.messageLength); this.getStats().incMessagesBeingReceived(true, header.messageLength); long startSer = this.getStats().startMsgDeserialization(); int position = nioInputBuffer.position(); int limit = nioInputBuffer.limit(); try { byteBufferInputStream.setBuffer(nioInputBuffer); ReplyProcessor21.initMessageRPId(); // dumpState("readMessage ready to deserialize", null, nioInputBuffer, position, limit); return (DistributionMessage) InternalDataSerializer.readDSFID(byteBufferInputStream); } catch (RuntimeException e) { throw e; } catch (IOException e) { throw e; } finally { this.getStats().endMsgDeserialization(startSer); this.getStats().decMessagesBeingReceived(header.messageLength); ioFilter.doneReading(nioInputBuffer); } }
} finally { if (doDecMessagesBeingReceived) { dm.getStats().decMessagesBeingReceived(this.bytesRead);
msg = md.getMessage(); } catch (ClassNotFoundException ex) { this.owner.getConduit().getStats().decMessagesBeingReceived(md.size()); failureMsg = "ClassNotFound deserializing message"; failureEx = ex; logger.fatal("ClassNotFound deserializing message: {}", ex.toString()); } catch (IOException ex) { this.owner.getConduit().getStats().decMessagesBeingReceived(md.size()); failureMsg = "IOException deserializing message"; failureEx = ex; this.owner.getConduit().getStats().decMessagesBeingReceived(md.size()); failureMsg = "Unexpected failure deserializing message"; failureEx = ex;