From d900c78f11b524bec7fdac7adebb310165930f22 Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Fri, 1 Apr 2016 09:51:44 -0500 Subject: [PATCH] Perform null check on super.getAsyncContext() Fixes gh-3780 --- .../security/web/servletapi/HttpServlet3RequestFactory.java | 3 +++ .../SecurityContextHolderAwareRequestFilterTests.java | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/web/src/main/java/org/springframework/security/web/servletapi/HttpServlet3RequestFactory.java b/web/src/main/java/org/springframework/security/web/servletapi/HttpServlet3RequestFactory.java index dce2b4ca56..5456ccb612 100644 --- a/web/src/main/java/org/springframework/security/web/servletapi/HttpServlet3RequestFactory.java +++ b/web/src/main/java/org/springframework/security/web/servletapi/HttpServlet3RequestFactory.java @@ -177,6 +177,9 @@ final class HttpServlet3RequestFactory implements HttpServletRequestFactory { public AsyncContext getAsyncContext() { AsyncContext asyncContext = super.getAsyncContext(); + if (asyncContext == null) { + return null; + } return new SecurityContextAsyncContext(asyncContext); } diff --git a/web/src/test/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestFilterTests.java b/web/src/test/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestFilterTests.java index 1bd66565e2..0bf7c983de 100644 --- a/web/src/test/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestFilterTests.java +++ b/web/src/test/java/org/springframework/security/web/servletapi/SecurityContextHolderAwareRequestFilterTests.java @@ -300,6 +300,12 @@ public class SecurityContextHolderAwareRequestFilterTests { this.logoutHandler); } + // gh-3780 + @Test + public void getAsyncContextNullFromSuper() throws Exception { + assertThat(wrappedRequest().getAsyncContext()).isNull(); + } + @Test public void getAsyncContextStart() throws Exception { ArgumentCaptor runnableCaptor = ArgumentCaptor.forClass(Runnable.class);