@Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException {

        long size = request.getContentLengthLong();

        if (size > maxSize || isChunked(request)) {
            // Size it's either unknown or too large
            HttpServletResponse httpResponse = (HttpServletResponse) response;
            httpResponse.sendError(HttpServletResponse.SC_BAD_REQUEST, "Bad Request");
        } else {
            chain.doFilter(request, response);
        }
    }
@Test
    public void testDoFilterInvokeChainDoFilter() throws ServletException, IOException {
        MaxRequestSizeFilter maxRequestSizeFilter = new MaxRequestSizeFilter(MAX_SIZE);
        FilterChain spyFilterChain = Mockito.spy(FilterChain.class);
        ServletRequest spyHttpServletRequest = Mockito.spy(ServletRequest.class);
        ServletResponse spyHttpServletResponse = Mockito.spy(ServletResponse.class);
        Mockito.doReturn(LEGAL_SIZE).when(spyHttpServletRequest).getContentLengthLong();
        maxRequestSizeFilter.doFilter(spyHttpServletRequest, spyHttpServletResponse, spyFilterChain);
        Mockito.verify(spyFilterChain).doFilter(spyHttpServletRequest,spyHttpServletResponse);
    }