@Override
    public FilterRegistration.Dynamic addFilter(String name, String filterClass) {
        try {
            Class<?> newFilterClass = getClassLoader().loadClass(filterClass);
            if (!Filter.class.isAssignableFrom(newFilterClass)) {
                throw new IllegalArgumentException(filterClass + " does not implement Filter");
            }
            @SuppressWarnings("unchecked")
            Class<? extends Filter> filterCastClass = (Class<? extends Filter>)newFilterClass;

            return addFilter(name, filterCastClass);
        } catch (ClassNotFoundException e) {
            log.error("Could not find filter class", e);
            throw new IllegalStateException("Filter class " + filterClass + " not found");
        }
    }
@Test
    void addFilter_doesNotImplementFilter_expectException() {
        AwsServletContext ctx = new AwsServletContext(null);
        try {
            ctx.addFilter("filter", this.getClass().getName());
        } catch (IllegalArgumentException e) {
            assertTrue(e.getMessage().startsWith(this.getClass().getName() + " does not implement Filter"));
            return;
        }
        fail("Expected IllegalArgumentException");
    }