@Override
    public Result invoke(Invoker<?> invoker, Invocation inv) throws RpcException {
        String accessLogKey = invoker.getUrl().getParameter(Constants.ACCESS_LOG_KEY);
        boolean isFixedPath = invoker.getUrl().getParameter(ACCESS_LOG_FIXED_PATH_KEY, true);
        if (StringUtils.isEmpty(accessLogKey) || "false".equalsIgnoreCase(accessLogKey)) {
            // Notice that disable accesslog of one service may cause the whole application to stop collecting
            // accesslog.
            // It's recommended to use application level configuration to enable or disable accesslog if dynamically
            // configuration is needed .
            if (future != null && !future.isCancelled()) {
                future.cancel(true);
                logger.info("Access log task cancelled ...");
            }
            return invoker.invoke(inv);
        }

        if (scheduled.compareAndSet(false, true)) {
            future = inv.getModuleModel()
                    .getApplicationModel()
                    .getFrameworkModel()
                    .getBeanFactory()
                    .getBean(FrameworkExecutorRepository.class)
                    .getSharedScheduledExecutor()
                    .scheduleWithFixedDelay(
                            new AccesslogRefreshTask(isFixedPath),
                            LOG_OUTPUT_INTERVAL,
                            LOG_OUTPUT_INTERVAL,
                            TimeUnit.MILLISECONDS);
            logger.info("Access log task started ...");
        }
        Optional<AccessLogData> optionalAccessLogData = Optional.empty();
        try {
            optionalAccessLogData = Optional.of(buildAccessLogData(invoker, inv));
        } catch (Throwable t) {
            logger.warn(
                    CONFIG_FILTER_VALIDATION_EXCEPTION,
                    "",
                    "",
                    "Exception in AccessLogFilter of service(" + invoker + " -> " + inv + ")",
                    t);
        }
        try {
            return invoker.invoke(inv);
        } finally {
            String finalAccessLogKey = accessLogKey;
            optionalAccessLogData.ifPresent(logData -> {
                logData.setOutTime(new Date());
                log(finalAccessLogKey, logData, isFixedPath);
            });
        }
    }
@Test
    @SuppressWarnings("unchecked")
    public void testDefault() throws NoSuchFieldException, IllegalAccessException {
        URL url = URL.valueOf("test://test:11/test?accesslog=true&group=dubbo&version=1.1");
        Invoker<AccessLogFilterTest> invoker = new MyInvoker<AccessLogFilterTest>(url);
        Invocation invocation = new MockInvocation();

        Field field = AccessLogFilter.class.getDeclaredField("logEntries");
        field.setAccessible(true);
        assertTrue(((Map) field.get(accessLogFilter)).isEmpty());

        accessLogFilter.invoke(invoker, invocation);

        Map<String, Queue<AccessLogData>> logs = (Map<String, Queue<AccessLogData>>) field.get(accessLogFilter);
        assertFalse(logs.isEmpty());
        assertFalse(logs.get("true").isEmpty());
        AccessLogData log = logs.get("true").iterator().next();
        assertEquals("org.apache.dubbo.rpc.support.DemoService", log.getServiceName());
    }