Skip to content

Commit

Permalink
Merge branch '1.7' into 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
keith-turner committed Oct 12, 2017
2 parents 0af1dba + 6ead474 commit ae3aa10
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -156,6 +156,10 @@ public static class Reader implements BlockFileReader {
private boolean closed = false;
private AccumuloConfiguration accumuloConfiguration = null;

// ACCUMULO-4716 - Define MAX_ARRAY_SIZE smaller than Integer.MAX_VALUE to prevent possible OutOfMemory
// errors when allocating arrays - described in stackoverflow post: https://stackoverflow.com/a/8381338
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;

private interface BlockLoader {
BlockReader get() throws IOException;

Expand Down Expand Up @@ -342,7 +346,7 @@ private BlockRead getBlock(String _lookup, BlockCache cache, BlockLoader loader)

private BlockRead cacheBlock(String _lookup, BlockCache cache, BlockReader _currBlock, String block) throws IOException {

if ((cache == null) || (_currBlock.getRawSize() > cache.getMaxSize())) {
if ((cache == null) || (_currBlock.getRawSize() > Math.min(cache.getMaxSize(), MAX_ARRAY_SIZE))) {
return new BlockRead(_currBlock, _currBlock.getRawSize());
} else {

Expand Down

0 comments on commit ae3aa10

Please sign in to comment.