{
int messageSize = fileBuffer.readInt();
int oldPos = fileBuffer.readerIndex();
if (fileBuffer.readerIndex() + messageSize < fileBuffer.capacity() && fileBuffer.getByte(oldPos + messageSize) == PageImpl.END_BYTE)
{
PagedMessage msg = new PagedMessageImpl();
msg.decode(fileBuffer);
byte b = fileBuffer.readByte();
if (b != PageImpl.END_BYTE)
{
// Sanity Check: This would only happen if there is a bug on decode or any internal code, as this
// constraint was already checked
throw new IllegalStateException("Internal error, it wasn't possible to locate END_BYTE " + b);
}
msg.initMessage(storage);
if (isTrace)
{
log.trace("Reading message " + msg + " on pageId=" + this.pageId + " for address=" + storeName);
}
messages.add(msg);