/** * Test that a connection that is aborted while calling isTableDisabled doesn't NPE */ @Test public void testTableDisabledRace() throws Exception { final HConnection connection = new HConnectionRaceTester(TEST_UTIL.getConfiguration(), true); MultithreadedTestUtil.TestContext ctx = new MultithreadedTestUtil.TestContext(TEST_UTIL.getConfiguration()); RepeatingTestThread disabledChecker = new RepeatingTestThread(ctx) { @Override public void doAnAction() throws IOException { try { connection.isTableDisabled(Bytes.toBytes("tableToCheck")); } catch (IOException ioe) { // Ignore. ZK can legitimately fail, only care if we get a NullPointerException } } }; AbortThread abortThread = new AbortThread(ctx, connection); ctx.addThread(disabledChecker); ctx.addThread(abortThread); ctx.startThreads(); ctx.waitFor(MILLIS_TO_WAIT_FOR_RACE); ctx.stop(); }
/** * Test that a connection that is aborted while calling getCurrentNrNRS doesn't NPE */ @Test public void testGetCurrentNrHRSRace() throws Exception { final HConnection connection = new HConnectionRaceTester(TEST_UTIL.getConfiguration(), true); MultithreadedTestUtil.TestContext ctx = new MultithreadedTestUtil.TestContext(TEST_UTIL.getConfiguration()); RepeatingTestThread getCurrentNrHRSCaller = new RepeatingTestThread(ctx) { @Override public void doAnAction() throws IOException { try { connection.getCurrentNrHRS(); } catch (IOException ioe) { // Ignore. ZK can legitimately fail, only care if we get a NullPointerException } } }; AbortThread abortThread = new AbortThread(ctx, connection); ctx.addThread(getCurrentNrHRSCaller); ctx.addThread(abortThread); ctx.startThreads(); ctx.waitFor(MILLIS_TO_WAIT_FOR_RACE); ctx.stop(); }