@Override
    protected void close() throws Exception {
        ZookeeperServiceWatch watch = (ZookeeperServiceWatch) target;
        final Field curator = watch.getClass().getDeclaredField("curator");
        AccessController.doPrivileged(new FieldAccessAction(curator));
        Field modifiersField = Field.class.getDeclaredField("modifiers");
        AccessController.doPrivileged(new FieldAccessAction(modifiersField));
        final CuratorFramework client = (CuratorFramework) curator.get(target);

        // Shut down the client and stop the timer
        client.close();
        final Field cache = watch.getClass().getDeclaredField("cache");
        AccessController.doPrivileged(new FieldAccessAction(cache));
        modifiersField.setInt(cache, cache.getModifiers() & ~Modifier.FINAL);

        // Clear the cache
        cache.set(target, null);
        LOGGER.warning("Zookeeper client has been closed by user.");
    }
@Test
    public void close() throws Exception {
        final CuratorFramework client = Mockito.mock(CuratorFramework.class);
        final ZookeeperServiceWatch watch = new ZookeeperServiceWatch(client, null);
        final ExecuteContext context = buildContext(watch, new Object[0]);
        interceptor.doBefore(context);
        interceptor.close();
        Mockito.verify(client, Mockito.times(1)).close();
    }