RequestTracingFilter implements Filter { protected ServletRuntime getServletRuntime(ServletRequest request) { if (servletRuntime == null) { servletRuntime = ServletRuntime.determineServletRuntime(request.getClass(), ASYNC_LISTENER_CLASSNAME); } return servletRuntime; }  @Override @SuppressWarnings("RedundantThrows") void init(FilterConfig filterConfig); @Override void destroy(); @Override void doFilter(ServletRequest request,
                         ServletResponse response,
                         FilterChain filterChain); static final String FILTER_HAS_ALREADY_EXECUTED_ATTRIBUTE; @Deprecated
    static final String ERROR_REQUEST_URI_ATTRIBUTE; static final String USER_ID_HEADER_KEYS_LIST_INIT_PARAM_NAME; static final String TAG_AND_SPAN_NAMING_STRATEGY_INIT_PARAM_NAME; static final String TAG_AND_SPAN_NAMING_ADAPTER_INIT_PARAM_NAME; }
@Test public void getServletRuntime_returns_value_of_ServletRuntime_determineServletRuntime_method_and_caches_result() { Class<? extends ServletRuntime> expectedServletRuntimeClass = ServletRuntime.determineServletRuntime(requestMock.getClass(), ASYNC_LISTENER_CLASSNAME).getClass(); RequestTracingFilter filter = getBasicFilter(); assertThat(filter.servletRuntime).isNull(); ServletRuntime result = filter.getServletRuntime(requestMock); assertThat(result.getClass()).isEqualTo(expectedServletRuntimeClass); assertThat(filter.servletRuntime).isSameAs(result); }
@Test public void getServletRuntime_uses_cached_value_if_possible() { RequestTracingFilter filterSpy = spy(getBasicFilter()); ServletRuntime servletRuntimeMock = mock(ServletRuntime.class); filterSpy.servletRuntime = servletRuntimeMock; ServletRuntime result = filterSpy.getServletRuntime(mock(HttpServletRequest.class)); assertThat(result).isSameAs(servletRuntimeMock); }