accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmil...@apache.org
Subject [accumulo] branch master updated: Fix NPE in BCFile. Fixes #1021 (#1022)
Date Mon, 11 Mar 2019 20:14:17 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new 8a85a38  Fix NPE in BCFile. Fixes #1021 (#1022)
8a85a38 is described below

commit 8a85a3847bf77a11569f115eda17c7b7045431d3
Author: Mike Miller <mmiller@apache.org>
AuthorDate: Mon Mar 11 16:14:12 2019 -0400

    Fix NPE in BCFile. Fixes #1021 (#1022)
    
    * Add cache to old RFile tests to test for this error
---
 .../accumulo/core/file/rfile/bcfile/BCFile.java    |  2 ++
 .../apache/accumulo/core/file/rfile/RFileTest.java | 28 ++++++++++++++--------
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/BCFile.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/BCFile.java
index cf9151d..d19db5b 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/BCFile.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/BCFile.java
@@ -36,6 +36,7 @@ import java.util.TreeMap;
 import org.apache.accumulo.core.crypto.CryptoUtils;
 import org.apache.accumulo.core.cryptoImpl.CryptoEnvironmentImpl;
 import org.apache.accumulo.core.cryptoImpl.NoFileDecrypter;
+import org.apache.accumulo.core.cryptoImpl.NoFileEncrypter;
 import org.apache.accumulo.core.file.rfile.bcfile.Compression.Algorithm;
 import org.apache.accumulo.core.file.rfile.bcfile.Utils.Version;
 import org.apache.accumulo.core.file.streams.BoundedRangeFileInputStream;
@@ -634,6 +635,7 @@ public final class BCFile {
       // backwards compatibility
       if (version.equals(API_VERSION_1)) {
         LOG.trace("Found a version 1 file to read.");
+        decryptionParams = new NoFileEncrypter().getDecryptionParameters();
         this.decrypter = new NoFileDecrypter();
       } else {
         // read crypto parameters and get decrypter
diff --git a/core/src/test/java/org/apache/accumulo/core/file/rfile/RFileTest.java b/core/src/test/java/org/apache/accumulo/core/file/rfile/RFileTest.java
index 7cf5fdd..9e70010 100644
--- a/core/src/test/java/org/apache/accumulo/core/file/rfile/RFileTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/file/rfile/RFileTest.java
@@ -1702,28 +1702,28 @@ public class RFileTest {
 
   @Test(expected = NullPointerException.class)
   public void testMissingUnreleasedVersions() throws Exception {
-    runVersionTest(5, DefaultConfiguration.getInstance());
+    runVersionTest(5, getAccumuloConfig(CryptoTest.CRYPTO_OFF_CONF));
   }
 
   @Test
   public void testOldVersions() throws Exception {
-    AccumuloConfiguration defaultConfiguration = DefaultConfiguration.getInstance();
-    runVersionTest(3, defaultConfiguration);
-    runVersionTest(4, defaultConfiguration);
-    runVersionTest(6, defaultConfiguration);
-    runVersionTest(7, defaultConfiguration);
+    ConfigurationCopy defaultConf = getAccumuloConfig(CryptoTest.CRYPTO_OFF_CONF);
+    runVersionTest(3, defaultConf);
+    runVersionTest(4, defaultConf);
+    runVersionTest(6, defaultConf);
+    runVersionTest(7, defaultConf);
   }
 
   @Test
   public void testOldVersionsWithCrypto() throws Exception {
-    AccumuloConfiguration cryptoOnConf = getAccumuloConfig(CryptoTest.CRYPTO_ON_CONF);
+    ConfigurationCopy cryptoOnConf = getAccumuloConfig(CryptoTest.CRYPTO_ON_CONF);
     runVersionTest(3, cryptoOnConf);
     runVersionTest(4, cryptoOnConf);
     runVersionTest(6, cryptoOnConf);
     runVersionTest(7, cryptoOnConf);
   }
 
-  private void runVersionTest(int version, AccumuloConfiguration aconf) throws IOException
{
+  private void runVersionTest(int version, ConfigurationCopy aconf) throws Exception {
     InputStream in = this.getClass().getClassLoader()
         .getResourceAsStream("org/apache/accumulo/core/file/rfile/ver_" + version + ".rf");
     ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -1735,8 +1735,15 @@ public class RFileTest {
     byte[] data = baos.toByteArray();
     SeekableByteArrayInputStream bais = new SeekableByteArrayInputStream(data);
     FSDataInputStream in2 = new FSDataInputStream(bais);
+    aconf.set(Property.TSERV_CACHE_MANAGER_IMPL, LruBlockCacheManager.class.getName());
+    aconf.set(Property.TSERV_DEFAULT_BLOCKSIZE, Long.toString(100000));
+    aconf.set(Property.TSERV_DATACACHE_SIZE, Long.toString(100000000));
+    aconf.set(Property.TSERV_INDEXCACHE_SIZE, Long.toString(100000000));
+    BlockCacheManager manager = BlockCacheManagerFactory.getInstance(aconf);
+    manager.start(new BlockCacheConfiguration(aconf));
     CachableBuilder cb = new CachableBuilder().input(in2).length(data.length).conf(hadoopConf)
-        .cryptoService(CryptoServiceFactory.newInstance(aconf, ClassloaderType.JAVA));
+        .cryptoService(CryptoServiceFactory.newInstance(aconf, ClassloaderType.JAVA))
+        .index(manager.getBlockCache(CacheType.INDEX)).data(manager.getBlockCache(CacheType.DATA));
     Reader reader = new RFile.Reader(cb);
     checkIndex(reader);
 
@@ -1779,10 +1786,11 @@ public class RFileTest {
       assertFalse(iter.hasTop());
     }
 
+    manager.stop();
     reader.close();
   }
 
-  public static AccumuloConfiguration getAccumuloConfig(String cryptoOn) {
+  public static ConfigurationCopy getAccumuloConfig(String cryptoOn) {
     ConfigurationCopy cfg = new ConfigurationCopy(DefaultConfiguration.getInstance());
     switch (cryptoOn) {
       case CryptoTest.CRYPTO_ON_CONF:


Mime
View raw message