org.apache.catalina.connector.ClientAbortException Java Examples

The following examples show how to use org.apache.catalina.connector.ClientAbortException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DelegateRequestMatchingFilter.java    From youkefu with Apache License 2.0 6 votes vote down vote up
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
     HttpServletRequest request = (HttpServletRequest) req;
     boolean matchAnyRoles = false ;
     for(RequestMatcher anyRequest : ignoredRequests ){
    	 if(anyRequest.matches(request)){
    		 matchAnyRoles = true ;
    	 }
     }
     User user = (User) request.getSession().getAttribute(UKDataContext.USER_SESSION_NAME) ;
     if(matchAnyRoles){
    	 if(user !=null && "0".equals(user.getUsertype())){
    		 chain.doFilter(req,resp);
    	 }else{
     	 //重定向到 无权限执行操作的页面
     	 HttpServletResponse response = (HttpServletResponse) resp ;
     	 response.sendRedirect("/?msg=security");
    	 }
     }else{
    	 try{
    		 chain.doFilter(req,resp);
    	 }catch(ClientAbortException ex){
    		 //Tomcat异常,不做处理
    	 }
     }
}
 
Example #2
Source File: AbstractAccessLogValve.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public void addElement(CharArrayWriter buf, Date date, Request request, Response response, long time) {
    if (response != null && request != null) {
        boolean statusFound = false;

        // Check whether connection IO is in "not allowed" state
        AtomicBoolean isIoAllowed = new AtomicBoolean(false);
        request.getCoyoteRequest().action(ActionCode.IS_IO_ALLOWED, isIoAllowed);
        if (!isIoAllowed.get()) {
            buf.append('X');
            statusFound = true;
        } else {
            // Check for connection aborted cond
            if (response.isError()) {
                Throwable ex = (Throwable) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
                if (ex instanceof ClientAbortException) {
                    buf.append('X');
                    statusFound = true;
                }
            }
        }

        // If status is not found yet, cont to check whether connection is keep-alive or close
        if (!statusFound) {
            String connStatus = response.getHeader(org.apache.coyote.http11.Constants.CONNECTION);
            if (org.apache.coyote.http11.Constants.CLOSE.equalsIgnoreCase(connStatus)) {
                buf.append('-');
            } else {
                buf.append('+');
            }
        }
    } else {
        // Unknown connection status
        buf.append('?');
    }
}
 
Example #3
Source File: GlobleExceptionHandler.java    From zfile with MIT License 5 votes vote down vote up
/**
 * 捕获 ClientAbortException 异常, 不做任何处理, 防止出现大量堆栈日志输出, 此异常不影响功能.
 */
@ExceptionHandler({HttpMediaTypeNotAcceptableException.class, ClientAbortException.class})
@ResponseBody
@ResponseStatus
public void clientAbortException(Exception ex) {
    // if (log.isDebugEnabled()) {
    //     log.debug("出现了断开异常:", ex);
    // }
}
 
Example #4
Source File: WebExceptionHandler.java    From Shiro-Action with MIT License 5 votes vote down vote up
/**
 * 捕获 ClientAbortException 异常, 不做任何处理, 防止出现大量堆栈日志输出, 此异常不影响功能.
 */
@ExceptionHandler({HttpMediaTypeNotAcceptableException.class, ClientAbortException.class})
@ResponseBody
@ResponseStatus
public void clientAbortException(Exception ex) {
    if (log.isDebugEnabled()) {
        log.debug("出现了断开异常:", ex);
    }
}
 
Example #5
Source File: GlobalExceptionHandler.java    From find with MIT License 5 votes vote down vote up
@ExceptionHandler(ClientAbortException.class)
@ResponseBody
public ErrorResponse connectionAbort(final ClientAbortException e) {
    // Tomcat-specific exception when existing request is aborted by client
    log.debug("Client aborted connection", e);
    return null;
}
 
Example #6
Source File: ViewHelper.java    From fess with Apache License 2.0 5 votes vote down vote up
protected StreamResponse writeContent(final String configId, final String url, final CrawlerClient client) {
    final StreamResponse response = new StreamResponse(StringUtil.EMPTY);
    final ResponseData responseData = client.execute(RequestDataBuilder.newRequestData().get().url(url).build());
    if (responseData.getHttpStatusCode() == 404) {
        response.httpStatus(responseData.getHttpStatusCode());
        CloseableUtil.closeQuietly(responseData);
        return response;
    }
    writeFileName(response, responseData);
    writeContentType(response, responseData);
    writeNoCache(response, responseData);
    response.stream(out -> {
        try (final InputStream is = new BufferedInputStream(responseData.getResponseBody())) {
            out.write(is);
        } catch (final IOException e) {
            if (!(e.getCause() instanceof ClientAbortException)) {
                throw new FessSystemException("Failed to write a content. configId: " + configId + ", url: " + url, e);
            }
        } finally {
            CloseableUtil.closeQuietly(responseData);
        }
        if (logger.isDebugEnabled()) {
            logger.debug("Finished to write {}", url);
        }
    });
    return response;
}
 
Example #7
Source File: GlobalExceptionHandler.java    From Blog with Apache License 2.0 2 votes vote down vote up
/**
     * 客户端错误
     *
     * @param e
     * @return
     */
    @ExceptionHandler(ClientAbortException.class)
    public Result clientAbortExceptionException(Exception e) {
//        e.printStackTrace();
        return Result.create(StatusCode.ERROR, "客户端错误");
    }