Fix NullPointer when requesting a session that does not exist

See gh-11202
pull/11213/merge
petar.tahchiev 7 years ago committed by Stephane Nicoll
parent 6cae9257fe
commit 35c6dc4e3b

@ -60,6 +60,9 @@ public class SessionsEndpoint {
@ReadOperation @ReadOperation
public SessionDescriptor getSession(@Selector String sessionId) { public SessionDescriptor getSession(@Selector String sessionId) {
Session session = this.sessionRepository.findById(sessionId); Session session = this.sessionRepository.findById(sessionId);
if (session == null) {
return null;
}
return new SessionDescriptor(session); return new SessionDescriptor(session);
} }

@ -80,6 +80,12 @@ public class SessionsEndpointWebIntegrationTests {
.isEqualTo(new JSONArray().appendElement(session.getId())); .isEqualTo(new JSONArray().appendElement(session.getId()));
} }
@Test
public void sessionForIdNotFound() {
client.get().uri((builder) -> builder.path("/actuator/sessions/some-session-id-that-does-not-exist")
.build()).exchange().expectStatus().isNotFound();
}
@Configuration @Configuration
protected static class TestConfiguration { protected static class TestConfiguration {

Loading…
Cancel
Save