@Override
    public synchronized void cancel(final BackgroundAction action) {
        if(action.isRunning()) {
            log.debug(String.format("Skip removing action %s currently running", action));
        }
        else {
            this.remove(action);
        }
    }
@Test
    public void testCancel() {
        BackgroundActionRegistry r = new BackgroundActionRegistry();
        final AbstractBackgroundAction action = new AbstractBackgroundAction() {
            @Override
            public Object run() {
                return null;
            }
        };
        assertTrue(r.add(action));
        action.cancel();
        r.remove(action);
        assertFalse(r.contains(action));
        assertNull(r.getCurrent());
    }