accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject [accumulo] branch 1.7 updated: ACCUMULO-4716 Don't cache blks over max array size
Date Thu, 12 Oct 2017 17:34:40 GMT
This is an automated email from the ASF dual-hosted git repository.

kturner pushed a commit to branch 1.7
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/1.7 by this push:
     new 6ead474  ACCUMULO-4716 Don't cache blks over max array size
6ead474 is described below

commit 6ead4740dbc24485b51d73d0a006d44bb2f52833
Author: Mark Owens <jmarkowe@gmail.com>
AuthorDate: Thu Oct 5 18:02:18 2017 -0400

    ACCUMULO-4716 Don't cache blks over max array size
    
    Prevents byte array from caching up to Integer.MAX_VALUE to prevent
    possible OutofMemory error as described in StackOverflow post
    https://stackoverflow.com/a/8381338
---
 .../apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java
b/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java
index 7daacb7..3c5095e 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java
@@ -145,6 +145,10 @@ public class CachableBlockFile {
     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;
 
@@ -321,7 +325,7 @@ public class CachableBlockFile {
 
     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 {
 

-- 
To stop receiving notification emails like this one, please contact
['"commits@accumulo.apache.org" <commits@accumulo.apache.org>'].

Mime
View raw message