RequestTracingFilter implements Filter { @SuppressWarnings("unchecked") protected HttpTagAndSpanNamingAdapter<HttpServletRequest, HttpServletResponse> getTagAdapterFromName( String adapterName ) throws ClassNotFoundException, IllegalAccessException, InstantiationException { if (StringUtils.isBlank(adapterName)) { return getDefaultTagAdapter(); } return (HttpTagAndSpanNamingAdapter<HttpServletRequest, HttpServletResponse>) Class.forName(adapterName).newInstance(); }  @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; }
@DataProvider(value = { "true", "false" }) @Test public void getTagAdapterFromName_returns_expected_strategy_for_fully_qualified_classname( boolean useClassThatExists ) { RequestTracingFilter filter = new RequestTracingFilter(); String classname = (useClassThatExists) ? TagAdapterExtension.class.getName() : "foo.doesnotexist.BlahAdapter" + UUID.randomUUID().toString(); AtomicReference<HttpTagAndSpanNamingAdapter<HttpServletRequest, HttpServletResponse>> resultHolder = new AtomicReference<>(); Throwable ex = catchThrowable(() -> resultHolder.set(filter.getTagAdapterFromName(classname))); if (useClassThatExists) { assertThat(ex).isNull(); assertThat(resultHolder.get()) .isNotNull() .isInstanceOf(TagAdapterExtension.class); } else { assertThat(ex).isInstanceOf(ClassNotFoundException.class); assertThat(resultHolder.get()).isNull(); } }