You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After migrating from Spring 4.3.12, we're now seeing NullPointerExceptions as a result of the code for #19755. During debugging, we see that the attributes field on the session is null. As a result, the Collections.list(session.getAttributeNames)) throws the NPE.
Partial stacktrace:
java.lang.NullPointerException
at java.util.Collections.list(Collections.java:5239)
at org.springframework.test.web.servlet.result.PrintingResultHandler.getSessionAttributes(PrintingResultHandler.java:152)
at org.springframework.test.web.servlet.result.PrintingResultHandler.printRequest(PrintingResultHandler.java:120)
at org.springframework.test.web.servlet.result.PrintingResultHandler.handle(PrintingResultHandler.java:87)
at org.springframework.test.web.servlet.MockMvc$1.andDo(MockMvc.java:184)
Randy Cramp opened SPR-16164 and commented
After migrating from Spring 4.3.12, we're now seeing NullPointerExceptions as a result of the code for #19755. During debugging, we see that the attributes field on the session is null. As a result, the Collections.list(session.getAttributeNames)) throws the NPE.
Partial stacktrace:
java.lang.NullPointerException
at java.util.Collections.list(Collections.java:5239)
at org.springframework.test.web.servlet.result.PrintingResultHandler.getSessionAttributes(PrintingResultHandler.java:152)
at org.springframework.test.web.servlet.result.PrintingResultHandler.printRequest(PrintingResultHandler.java:120)
at org.springframework.test.web.servlet.result.PrintingResultHandler.handle(PrintingResultHandler.java:87)
at org.springframework.test.web.servlet.MockMvc$1.andDo(MockMvc.java:184)
Code snippet:
MockHttpSession session = Mockito.mock(MockHttpSession.class);
MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.post("/dummy-url")
.contentType(MediaType.APPLICATION_JSON_UTF8)
.header(HEADER_ENDPOINT, endpointUrl)
.content(someContent);
requestBuilder.session(session);
MockMvc mockMvc = MockMvcBuilders.standaloneSetup(endpointController).build();
mockMvc.perform(requestBuilder)
.andDo(print())
.andExpect(status().isOk());
Affects: 5.0.1
Reference URL: #19755
Issue Links:
Referenced from: commits 4ec60f0
The text was updated successfully, but these errors were encountered: