changeset 690:fdeaeb7d4da2

NcDataHelper bugfixes
author Devel 2
date Mon, 27 Nov 2017 09:57:23 +0100
parents 70cfe98e9556
children 9ccc2452b92c
files stress-tester/src/main/java/com/passus/st/reader/nc/NcDataHelper.java
diffstat 1 files changed, 6 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/reader/nc/NcDataHelper.java	Mon Nov 27 09:22:06 2017 +0100
+++ b/stress-tester/src/main/java/com/passus/st/reader/nc/NcDataHelper.java	Mon Nov 27 09:57:23 2017 +0100
@@ -56,15 +56,13 @@
     }
 
     public ByteString readByteStringTerminated(ByteBuff buffer, byte delim) {
-        int startIndex = buffer.startIndex();
-        int endIndex = ByteBuffUtils.localize(buffer, startIndex, delim);
+        int endIndex = buffer.indexOf(delim);
         if (endIndex == -1) {
             return null;
         }
 
-        int length = endIndex - startIndex;
-        ByteString result = buffer.toByteString(startIndex, endIndex);
-        buffer.skipBytes(length + 1);
+        ByteString result = buffer.toByteString(0, endIndex);
+        buffer.skipBytes(endIndex + 1);
         return result;
     }
 
@@ -101,7 +99,7 @@
     }
 
     public int writeIntVLC(int value, ByteBuff buffer) {
-        int len = writeIntVLC(value, buffer.buffer(), buffer.startIndex(), buffer.capacity());
+        int len = writeIntVLC(value, buffer.buffer(), buffer.endIndex(), buffer.capacity());
         buffer.endIndex(buffer.endIndex() + len);
         return len;
     }
@@ -172,8 +170,8 @@
     }
 
     public int writeLongVLC(long value, ByteBuff buffer) {
-        int len = writeLongVLC(value, buffer.buffer(), buffer.startIndex(), buffer.capacity());
-        buffer.skipBytes(len);
+        int len = writeLongVLC(value, buffer.buffer(), buffer.endIndex(), buffer.capacity());
+        buffer.endIndex(buffer.endIndex() + len);
         return len;
     }