Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE when Clean.apply called with null as first argument #3736

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private Boolean apply(Boolean res, Throwable err)
final int tasks = numPendingTasks.decrementAndGet();

// if the cleaning job was scheduled (res == true) or had an error, trigger again after decrementing the tasks
if ((res || err != null) && pool.needsCleaning())
if (((res != null && res) || err != null) && pool.needsCleaning())
wait.signal();

if (err != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.when;

public class MemtableCleanerThreadTest
Expand Down Expand Up @@ -111,6 +112,22 @@ public void testCleanerInvoked() throws Exception
stopThread();
}

@Test
public void testCleanerError() throws Exception
{
when(pool.needsCleaning()).thenReturn(false);
AsyncPromise<Boolean > fut = new AsyncPromise<>();
cleaner = () -> {
return fut;
};

Clean<> clean = new Clean<>(pool, cleaner);

Boolean res = clean.apply(null, null);

assertNull(res);
}

@Test
public void testCleanerError() throws Exception
{
Expand Down