Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

com.rop.impl.AnnotationServletServiceRouter多处空指针异常 #3

Open
xiegengcai opened this issue Nov 5, 2012 · 0 comments
Open

Comments

@xiegengcai
Copy link

下面两个方法很明显,一旦异常,在catch中会有个空指针异常

/**
* 在服务调用之前拦截
*
* @param ropRequestContext
*/
private void invokeBeforceServiceOfInterceptors(RopRequestContext ropRequestContext) {
Interceptor tempInterceptor = null;
try {
if (interceptors != null && interceptors.size() > 0) {
for (Interceptor interceptor : interceptors) {

                interceptor.beforeService(ropRequestContext);

                //如果有一个产生了响应,则阻止后续的调用
                if (ropRequestContext.getRopResponse() != null) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("拦截器[" + interceptor.getClass().getName() + "]产生了一个RopResponse," +
                                " 阻止本次服务请求继续,服务将直接返回。");
                    }
                    return;
                }
            }
        }
    } catch (Throwable e) {
        ropRequestContext.setRopResponse(new ServiceUnavailableErrorResponse(ropRequestContext.getMethod(), ropRequestContext.getLocale(), e));
        logger.error("在执行拦截器[" + tempInterceptor.getClass().getName() + "]时发生异常.", e);
    }
}

/**
 * 在服务调用之后,返回响应之前拦截
 *
 * @param ropRequestContext
 */
private void invokeBeforceResponseOfInterceptors(RopRequestContext ropRequestContext) {
    Interceptor tempInterceptor = null;
    try {
        if (interceptors != null && interceptors.size() > 0) {
            for (Interceptor interceptor : interceptors) {
                interceptor.beforeResponse(ropRequestContext);
            }
        }
    } catch (Throwable e) {
        ropRequestContext.setRopResponse(new ServiceUnavailableErrorResponse(ropRequestContext.getMethod(), ropRequestContext.getLocale(), e));
        logger.error("在执行拦截器[" + tempInterceptor.getClass().getName() + "]时发生异常.", e);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant