From 826af6f4801b254624b1e285ebc0968e39683176 Mon Sep 17 00:00:00 2001 From: Ivan Bella Date: Tue, 11 Oct 2016 20:20:10 -0400 Subject: [PATCH] ACCUMULO-4483 Added another test case that forces the exception by reseeking the in memory map iterator to the same location after forcing a switch. --- .../accumulo/tserver/InMemoryMapTest.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java b/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java index 59dc68e9739..f813d4278b3 100644 --- a/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java +++ b/server/tserver/src/test/java/org/apache/accumulo/tserver/InMemoryMapTest.java @@ -141,6 +141,13 @@ static void ae(SortedKeyValueIterator dc, String row, String column, } + static void aeNoNext(SortedKeyValueIterator dc, String row, String column, int ts, String val) throws IOException { + assertTrue(dc.hasTop()); + assertEquals(nk(row, column, ts), dc.getTopKey()); + assertEquals(new Value(val.getBytes()), dc.getTopValue()); + + } + static Set newCFSet(String... cfs) { HashSet cfSet = new HashSet<>(); for (String cf : cfs) { @@ -247,6 +254,25 @@ public void test4() throws Exception { ski1.close(); } + @Test + public void testDecodeValueModification() throws Exception { + // This test case is the fix for ACCUMULO-4483 + InMemoryMap imm = newInMemoryMap(false, tempFolder.newFolder().getAbsolutePath()); + + mutate(imm, "r1", "foo:cq1", 3, ""); + MemoryIterator ski1 = imm.skvIterator(null); + + imm.delete(0); + + ski1.seek(new Range(new Text("r1")), LocalityGroupUtil.EMPTY_CF_SET, false); + aeNoNext(ski1, "r1", "foo:cq1", 3, ""); + ski1.seek(new Range(new Text("r1")), LocalityGroupUtil.EMPTY_CF_SET, false); + ae(ski1, "r1", "foo:cq1", 3, ""); + assertFalse(ski1.hasTop()); + + ski1.close(); + } + @Test public void test5() throws Exception { InMemoryMap imm = newInMemoryMap(false, tempFolder.newFolder().getAbsolutePath());