You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by kt...@apache.org on 2012/12/27 21:21:24 UTC

svn commit: r1426302 - in /accumulo/trunk/core/src: main/java/org/apache/accumulo/core/iterators/system/VisibilityFilter.java test/java/org/apache/accumulo/core/iterators/system/VisibilityFilterTest.java

Author: kturner
Date: Thu Dec 27 20:21:23 2012
New Revision: 1426302

URL: http://svn.apache.org/viewvc?rev=1426302&view=rev
Log:
ACCUMULO-844 made visibilityfilter catch badargument exception

Added:
    accumulo/trunk/core/src/test/java/org/apache/accumulo/core/iterators/system/VisibilityFilterTest.java
Modified:
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/system/VisibilityFilter.java

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/system/VisibilityFilter.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/system/VisibilityFilter.java?rev=1426302&r1=1426301&r2=1426302&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/system/VisibilityFilter.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/iterators/system/VisibilityFilter.java Thu Dec 27 20:21:23 2012
@@ -25,6 +25,7 @@ import org.apache.accumulo.core.security
 import org.apache.accumulo.core.security.ColumnVisibility;
 import org.apache.accumulo.core.security.VisibilityEvaluator;
 import org.apache.accumulo.core.security.VisibilityParseException;
+import org.apache.accumulo.core.util.BadArgumentException;
 import org.apache.accumulo.core.util.TextUtil;
 import org.apache.commons.collections.map.LRUMap;
 import org.apache.hadoop.io.Text;
@@ -73,6 +74,9 @@ public class VisibilityFilter extends Fi
     } catch (VisibilityParseException e) {
       log.error("Parse Error", e);
       return false;
+    } catch (BadArgumentException e) {
+      log.error("Parse Error", e);
+      return false;
     }
   }
 }

Added: accumulo/trunk/core/src/test/java/org/apache/accumulo/core/iterators/system/VisibilityFilterTest.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/test/java/org/apache/accumulo/core/iterators/system/VisibilityFilterTest.java?rev=1426302&view=auto
==============================================================================
--- accumulo/trunk/core/src/test/java/org/apache/accumulo/core/iterators/system/VisibilityFilterTest.java (added)
+++ accumulo/trunk/core/src/test/java/org/apache/accumulo/core/iterators/system/VisibilityFilterTest.java Thu Dec 27 20:21:23 2012
@@ -0,0 +1,52 @@
+/**
+ * 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.
+ */
+package org.apache.accumulo.core.iterators.system;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.TreeMap;
+
+import junit.framework.TestCase;
+
+import org.apache.accumulo.core.data.ByteSequence;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.iterators.SortedMapIterator;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+
+public class VisibilityFilterTest extends TestCase {
+  
+  public void testBadVisibility() throws IOException {
+    TreeMap<Key,Value> tm = new TreeMap<Key,Value>();
+    
+    tm.put(new Key("r1", "cf1", "cq1", "A&"), new Value(new byte[0]));
+    VisibilityFilter filter = new VisibilityFilter(new SortedMapIterator(tm), new Authorizations("A"), "".getBytes());
+    
+    // suppress logging
+    Level prevLevel = Logger.getLogger(VisibilityFilter.class).getLevel();
+    Logger.getLogger(VisibilityFilter.class).setLevel(Level.FATAL);
+
+    filter.seek(new Range(), new HashSet<ByteSequence>(), false);
+    assertFalse(filter.hasTop());
+    
+    Logger.getLogger(VisibilityFilter.class).setLevel(prevLevel);
+  }
+  
+}