//检查状态机状态,如果不处于正常状态,则抛出异常 privatevoidcheck(){ if (request == null) { // AsyncContext has been recycled and should not be being used thrownew IllegalStateException(sm.getString("asyncContextImpl.requestEnded")); } }
@Override //每次获取request以及response对象,都检查请求以及应答对象是否已经被回收 public ServletRequest getRequest(){ check(); if (servletRequest == null) { thrownew IllegalStateException(sm.getString("asyncContextImpl.request.ise")); } return servletRequest; }
@Override //每次获取request以及response对象,都检查请求以及应答对象是否已经被回收 public ServletResponse getResponse(){ check(); if (servletResponse == null) { thrownew IllegalStateException(sm.getString("asyncContextImpl.response.ise")); } return servletResponse; } }