private void updateServiceInstance(ExecuteContext context) {
        final Object result = context.getResult();
        if (result instanceof Optional) {
            Optional<?> serverInstanceOption = (Optional<?>) result;
            if (!serverInstanceOption.isPresent()) {
                return;
            }
            RetryContext.INSTANCE.updateServiceInstance(serverInstanceOption.get());
        }
    }
@Test
    public void testBefore() throws Exception {
        final Interceptor interceptor = getInterceptor();
        final ExecuteContext context = interceptor.before(TestHelper.buildDefaultContext());
        assertNull(context.getResult());
        final RetryRule retryRule = new RetryRule();
        retryRule.setRetryOnSame(3);
        RetryContext.INSTANCE.buildRetryPolicy(retryRule);
        final Object instance = new Object();

        // simulated update instance
        RetryContext.INSTANCE.updateServiceInstance(instance);
        interceptor.before(context);
        assertTrue(context.getResult() instanceof Optional && ((Optional<?>) context.getResult()).isPresent());
        assertEquals(((Optional<?>) context.getResult()).get(), instance);
        RetryContext.INSTANCE.remove();
    }