Mercurial > stress-tester
changeset 759:a4e380627732
NcDataHelper bugfixes
author | Devel 2 |
---|---|
date | Fri, 15 Dec 2017 10:46:23 +0100 |
parents | d87032f02b94 |
children | d6c35bbbac02 |
files | stress-tester/src/main/java/com/passus/st/reader/nc/NcDataBlockReader.java stress-tester/src/main/java/com/passus/st/reader/nc/NcDataHelper.java |
diffstat | 2 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/reader/nc/NcDataBlockReader.java Fri Dec 15 10:25:12 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/reader/nc/NcDataBlockReader.java Fri Dec 15 10:46:23 2017 +0100 @@ -325,6 +325,8 @@ if (payloadBlock.dataSize() <= Integer.MAX_VALUE) { int dataSize = (int) payloadBlock.dataSize(); ByteBuff data = new HeapByteBuff(dataSize); + + //TODO - Mozna zoptymalizowac. Mozna kopiowac bufor bezposrednio do data readSessionPayloadBlockContent(data, dataSize); payloadBlock.data(data); } else {
--- a/stress-tester/src/main/java/com/passus/st/reader/nc/NcDataHelper.java Fri Dec 15 10:25:12 2017 +0100 +++ b/stress-tester/src/main/java/com/passus/st/reader/nc/NcDataHelper.java Fri Dec 15 10:46:23 2017 +0100 @@ -28,8 +28,12 @@ public static final int VLC_INT_TRESHOLD = 0x80; + public static final int VLC_INT_MAX_BYTES = 5; + public static final long VLC_LONG_TRESHOLD = 0x8000; + public static final int VLC_LONG_MAX_BYTES = 9; + public static final Charset CHARSET = Charset.forName("UTF-8"); private final MutableInt mutableInt = new MutableInt(); @@ -77,6 +81,7 @@ } public int writeIntVLC(ByteBuff buffer, int value) { + buffer.ensureCapacity(VLC_INT_MAX_BYTES); int len = writeIntVLC(buffer.buffer(), buffer.endIndex(), buffer.capacity(), value); buffer.endIndex(buffer.endIndex() + len); return len; @@ -163,6 +168,7 @@ } public int writeLongVLC(ByteBuff buffer, long value) { + buffer.ensureCapacity(VLC_LONG_MAX_BYTES); int len = writeLongVLC(buffer.buffer(), buffer.endIndex(), buffer.capacity(), value); buffer.endIndex(buffer.endIndex() + len); return len; @@ -259,7 +265,7 @@ } public int writeByteStringNullTerminated(ByteBuff buffer, ByteString value, boolean sanitize) { - buffer.ensureCapacity(value.length()); + buffer.ensureCapacity(value.length() + 1); int len = writeByteStringNullTerminated(buffer.buffer(), buffer.endIndex(), buffer.capacity(), value, sanitize); buffer.endIndex(buffer.endIndex() + len); return len;