From 58c1d547a01004a79c00723af45632c57f8d7d11 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Fri, 2 Nov 2018 04:14:24 +1100 Subject: [PATCH] Issue #3044 Use unwrapped session for SessionAsyncListener (#3053) * Issue #3044 Use unwrapped session for SessionAsyncListener --- .../jetty/server/session/SessionHandler.java | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java index e266a243eea..5dde83b28b6 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/session/SessionHandler.java @@ -158,19 +158,12 @@ public class SessionHandler extends ScopedHandler * has its session completed as the request exits the context. */ public class SessionAsyncListener implements AsyncListener - { - private Session _session; - - public SessionAsyncListener(Session session) - { - _session = session; - } - + { @Override public void onComplete(AsyncEvent event) throws IOException { //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 @@ -182,7 +175,7 @@ public class SessionHandler extends ScopedHandler @Override public void onError(AsyncEvent event) throws IOException { - complete(((HttpServletRequest)event.getAsyncContext().getRequest()).getSession(false)); + complete(Request.getBaseRequest(event.getAsyncContext().getRequest()).getSession(false)); } @Override @@ -190,7 +183,6 @@ public class SessionHandler extends ScopedHandler { event.getAsyncContext().addListener(this); } - } static final HttpSessionContext __nullSessionContext=new HttpSessionContext() @@ -251,6 +243,7 @@ public class SessionHandler extends ScopedHandler protected Scheduler _scheduler; 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) { - request.getAsyncContext().addListener(new SessionAsyncListener(session)); + request.getAsyncContext().addListener(_sessionAsyncListener); } else {