mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
HCOLL-211 Add BytesMarshaller and improve handling of invalid sizes.
This commit is contained in:
@@ -1952,7 +1952,6 @@ class StatelessServerConnector<K, V> {
|
||||
}
|
||||
|
||||
private void writeSizeAndFlags(long locationOfSize, boolean isException, Bytes out) {
|
||||
long currentPosition = out.position();
|
||||
final long size = out.position() - locationOfSize;
|
||||
out.writeInt(locationOfSize, (int) size); // size
|
||||
out.writeBoolean(locationOfSize + SIZE_OF_SIZE, isException); // isException
|
||||
@@ -1964,7 +1963,7 @@ class StatelessServerConnector<K, V> {
|
||||
|
||||
private Map<K, V> readEntries(Bytes reader) {
|
||||
final long numberOfEntries = reader.readStopBit();
|
||||
final HashMap<K, V> result = new HashMap<K, V>();
|
||||
final Map<K, V> result = new HashMap<K, V>();
|
||||
|
||||
ThreadLocalCopies copies = keyReaderWithSize.getCopies(null);
|
||||
BytesReader<K> keyReader = keyReaderWithSize.readerForLoop(copies);
|
||||
|
||||
@@ -89,11 +89,13 @@ public class StringEncodingExamplesTest {
|
||||
|
||||
@Override
|
||||
public CharSequence read(Bytes bytes) {
|
||||
int csLen = (int) bytes.readStopBit();
|
||||
long csLen = bytes.readStopBit();
|
||||
if (csLen < 0 || csLen > Integer.MAX_VALUE)
|
||||
throw new IllegalStateException("length invalid: " + csLen);
|
||||
if (returnedCharBuffer == null || returnedCharBuffer.capacity() < csLen) {
|
||||
returnedCharBuffer = CharBuffer.allocate(csLen);
|
||||
returnedCharBuffer = CharBuffer.allocate((int) csLen);
|
||||
} else {
|
||||
returnedCharBuffer.clear().limit(csLen);
|
||||
returnedCharBuffer.clear().limit((int) csLen);
|
||||
}
|
||||
bytesAsBuffer = bytes.sliceAsByteBuffer(bytesAsBuffer);
|
||||
decoder.decode(bytesAsBuffer, returnedCharBuffer, true);
|
||||
|
||||
Reference in New Issue
Block a user