incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ph...@apache.org
Subject git commit: BLUR-57. fix NPE in write through cache with empty index file
Date Thu, 07 Feb 2013 00:41:03 GMT
Updated Branches:
  refs/heads/0.2-dev e0e8c914d -> 4e1baef65


BLUR-57. fix NPE in write through cache with empty index file

Also added a test for the BlockDirectoryCache to verify the fix.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/4e1baef6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/4e1baef6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/4e1baef6

Branch: refs/heads/0.2-dev
Commit: 4e1baef656aa8113554e9431be5ac84ec4cd6cb7
Parents: e0e8c91
Author: Patrick Hunt <phunt@cloudera.com>
Authored: Wed Feb 6 16:39:05 2013 -0800
Committer: Patrick Hunt <phunt@cloudera.com>
Committed: Wed Feb 6 16:39:05 2013 -0800

----------------------------------------------------------------------
 .../blur/store/blockcache/BlockDirectoryCache.java |    4 +-
 .../store/blockcache/BlockDirectoryCacheTest.java  |   38 +++++++++++++++
 2 files changed, 41 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4e1baef6/src/blur-store/src/main/java/org/apache/blur/store/blockcache/BlockDirectoryCache.java
----------------------------------------------------------------------
diff --git a/src/blur-store/src/main/java/org/apache/blur/store/blockcache/BlockDirectoryCache.java
b/src/blur-store/src/main/java/org/apache/blur/store/blockcache/BlockDirectoryCache.java
index 46493f8..17155c9 100644
--- a/src/blur-store/src/main/java/org/apache/blur/store/blockcache/BlockDirectoryCache.java
+++ b/src/blur-store/src/main/java/org/apache/blur/store/blockcache/BlockDirectoryCache.java
@@ -69,6 +69,8 @@ public class BlockDirectoryCache implements Cache {
   @Override
   public void renameCacheFile(String source, String dest) {
     Integer file = _names.remove(source);
-    _names.put(dest, file);
+    if (file != null) {
+      _names.put(dest, file);
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/4e1baef6/src/blur-store/src/test/java/org/apache/blur/store/blockcache/BlockDirectoryCacheTest.java
----------------------------------------------------------------------
diff --git a/src/blur-store/src/test/java/org/apache/blur/store/blockcache/BlockDirectoryCacheTest.java
b/src/blur-store/src/test/java/org/apache/blur/store/blockcache/BlockDirectoryCacheTest.java
new file mode 100644
index 0000000..6a30d10
--- /dev/null
+++ b/src/blur-store/src/test/java/org/apache/blur/store/blockcache/BlockDirectoryCacheTest.java
@@ -0,0 +1,38 @@
+package org.apache.blur.store.blockcache;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import org.junit.Before;
+import org.junit.Test;
+
+public class BlockDirectoryCacheTest {
+  private BlockCache blockCache;
+  private BlockDirectoryCache blockDirectoryCache;
+
+  @Before
+  public void setup() {
+    int slabSize = BlockCache._8K * 1024;
+    long totalMemory = 2 * slabSize;
+    blockCache = new BlockCache(true, totalMemory, slabSize);
+    blockDirectoryCache = new BlockDirectoryCache(blockCache);
+  }
+
+  @Test
+  public void validateEmptyOutputFile() {
+    blockDirectoryCache.renameCacheFile("foo", "bar");
+  }
+}


Mime
View raw message