diff --git a/protocol/src/main/resources/scala/ByteBuffer.scala b/protocol/src/main/resources/scala/ByteBuffer.scala index 2416a7184..0e8a8469e 100644 --- a/protocol/src/main/resources/scala/ByteBuffer.scala +++ b/protocol/src/main/resources/scala/ByteBuffer.scala @@ -43,14 +43,14 @@ class ByteBuffer { def getWriteOffset: Int = writeOffset def setWriteOffset(writeIndex: Int): Unit = { - if (writeIndex > buffer.length) throw new RuntimeException("writeIndex[" + writeIndex + "] out of bounds exception: readerIndex: " + readOffset + ", writerIndex: " + writeOffset + "(expected: 0 <= readerIndex <= writerIndex <= capacity:" + buffer.length) + if (writeIndex > buffer.length) throw new RuntimeException("writeIndex[" + writeIndex + "] out of bounds exception: readOffset: " + readOffset + ", writeOffset: " + writeOffset + "(expected: 0 <= readOffset <= writeOffset <= capacity:" + buffer.length + ")") writeOffset = writeIndex } def getReadOffset: Int = readOffset def setReadOffset(readIndex: Int): Unit = { - if (readIndex > writeOffset) throw new RuntimeException("readIndex[" + readIndex + "] out of bounds exception: readerIndex: " + readOffset + ", writerIndex: " + writeOffset + "(expected: 0 <= readerIndex <= writerIndex <= capacity:" + buffer.length) + if (readIndex > writeOffset) throw new RuntimeException("readIndex[" + readIndex + "] out of bounds exception: readOffset: " + readOffset + ", writeOffset: " + writeOffset + "(expected: 0 <= readOffset <= writeOffset <= capacity:" + buffer.length + ")") readOffset = readIndex } diff --git a/protocol/src/test/scala/com/zfoo/scala/ByteBuffer.scala b/protocol/src/test/scala/com/zfoo/scala/ByteBuffer.scala index 608465992..88f908c84 100644 --- a/protocol/src/test/scala/com/zfoo/scala/ByteBuffer.scala +++ b/protocol/src/test/scala/com/zfoo/scala/ByteBuffer.scala @@ -43,14 +43,14 @@ class ByteBuffer { def getWriteOffset: Int = writeOffset def setWriteOffset(writeIndex: Int): Unit = { - if (writeIndex > buffer.length) throw new RuntimeException("writeIndex[" + writeIndex + "] out of bounds exception: readerIndex: " + readOffset + ", writerIndex: " + writeOffset + "(expected: 0 <= readerIndex <= writerIndex <= capacity:" + buffer.length) + if (writeIndex > buffer.length) throw new RuntimeException("writeIndex[" + writeIndex + "] out of bounds exception: readOffset: " + readOffset + ", writeOffset: " + writeOffset + "(expected: 0 <= readOffset <= writeOffset <= capacity:" + buffer.length + ")") writeOffset = writeIndex } def getReadOffset: Int = readOffset def setReadOffset(readIndex: Int): Unit = { - if (readIndex > writeOffset) throw new RuntimeException("readIndex[" + readIndex + "] out of bounds exception: readerIndex: " + readOffset + ", writerIndex: " + writeOffset + "(expected: 0 <= readerIndex <= writerIndex <= capacity:" + buffer.length) + if (readIndex > writeOffset) throw new RuntimeException("readIndex[" + readIndex + "] out of bounds exception: readOffset: " + readOffset + ", writeOffset: " + writeOffset + "(expected: 0 <= readOffset <= writeOffset <= capacity:" + buffer.length + ")") readOffset = readIndex }