Issue #3044 Use unwrapped session for SessionAsyncListener (#3053)

* Issue #3044 Use unwrapped session for SessionAsyncListener
This commit is contained in:
Jan Bartel 2018-11-02 04:14:24 +11:00 committed by GitHub
parent d33f65d322
commit 58c1d547a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 12 deletions

View File

@ -158,19 +158,12 @@ public class SessionHandler extends ScopedHandler
* has its session completed as the request exits the context. * has its session completed as the request exits the context.
*/ */
public class SessionAsyncListener implements AsyncListener public class SessionAsyncListener implements AsyncListener
{ {
private Session _session;
public SessionAsyncListener(Session session)
{
_session = session;
}
@Override @Override
public void onComplete(AsyncEvent event) throws IOException public void onComplete(AsyncEvent event) throws IOException
{ {
//An async request has completed, so we can complete the session //An async request has completed, so we can complete the session
complete(((HttpServletRequest)event.getAsyncContext().getRequest()).getSession(false)); complete(Request.getBaseRequest(event.getAsyncContext().getRequest()).getSession(false));
} }
@Override @Override
@ -182,7 +175,7 @@ public class SessionHandler extends ScopedHandler
@Override @Override
public void onError(AsyncEvent event) throws IOException public void onError(AsyncEvent event) throws IOException
{ {
complete(((HttpServletRequest)event.getAsyncContext().getRequest()).getSession(false)); complete(Request.getBaseRequest(event.getAsyncContext().getRequest()).getSession(false));
} }
@Override @Override
@ -190,7 +183,6 @@ public class SessionHandler extends ScopedHandler
{ {
event.getAsyncContext().addListener(this); event.getAsyncContext().addListener(this);
} }
} }
static final HttpSessionContext __nullSessionContext=new HttpSessionContext() static final HttpSessionContext __nullSessionContext=new HttpSessionContext()
@ -251,6 +243,7 @@ public class SessionHandler extends ScopedHandler
protected Scheduler _scheduler; protected Scheduler _scheduler;
protected boolean _ownScheduler = false; protected boolean _ownScheduler = false;
protected final SessionAsyncListener _sessionAsyncListener = new SessionAsyncListener();
@ -381,7 +374,7 @@ public class SessionHandler extends ScopedHandler
{ {
if (request.isAsyncStarted() && request.getDispatcherType() == DispatcherType.REQUEST) if (request.isAsyncStarted() && request.getDispatcherType() == DispatcherType.REQUEST)
{ {
request.getAsyncContext().addListener(new SessionAsyncListener(session)); request.getAsyncContext().addListener(_sessionAsyncListener);
} }
else else
{ {