mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
HCOLL-167 stopped the toString form overflowing the buffer
This commit is contained in:
@@ -1329,11 +1329,25 @@ class StatelessServerConnector<K, V> {
|
||||
|
||||
private Work toString(Bytes in, Bytes out) {
|
||||
long sizeLocation = reflectTransactionId(in, out);
|
||||
|
||||
String str;
|
||||
long remaining = out.remaining();
|
||||
try {
|
||||
out.writeObject(map.toString());
|
||||
str = map.toString();
|
||||
} catch (RuntimeException e) {
|
||||
return sendException(out, sizeLocation, e);
|
||||
}
|
||||
|
||||
assert remaining > 4;
|
||||
|
||||
// this stops the toString overflowing the buffer
|
||||
final String result = (str.length() < remaining) ?
|
||||
str :
|
||||
str.substring(0, (int) (remaining - 4)) + "...";
|
||||
|
||||
out.writeObject(str);
|
||||
|
||||
out.writeObject(result);
|
||||
writeSizeAndFlags(sizeLocation, false, out);
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user