HCOLL-197 - added better support for buffer resize to prevent issues around Integer.MAX_SIZE

This commit is contained in:
Rob Austin
2014-12-19 12:21:55 +00:00
parent 80c37e38f0
commit a47f177710
5 changed files with 138 additions and 32 deletions
@@ -477,6 +477,10 @@ abstract class AbstractChannelReplicator implements Closeable {
}
public boolean shouldBeIgnored(final Bytes entry, final int chronicleId) {
return !externalizable.identifierCheck(entry, chronicleId);
}
@Override
public boolean onEntry(final Bytes entry, final int chronicleId) {
@@ -494,8 +498,14 @@ abstract class AbstractChannelReplicator implements Closeable {
int entrySize = externalizable.sizeOfEntry(entry, chronicleId);
if (entrySize > in.remaining()) {
long newSize = in.position() + entrySize;
assert newSize < Integer.MAX_VALUE;
// This can occur when we pack a number of entries into the buffer and the
// last entry is very large.
if (newSize > Integer.MAX_VALUE)
return false;
resizeBuffer((int) newSize);
}