Fix NullPointer when requesting a session that does not exist
See gh-11202
This commit is contained in:
committed by
Stephane Nicoll
parent
6cae9257fe
commit
35c6dc4e3b
@@ -60,6 +60,9 @@ public class SessionsEndpoint {
|
||||
@ReadOperation
|
||||
public SessionDescriptor getSession(@Selector String sessionId) {
|
||||
Session session = this.sessionRepository.findById(sessionId);
|
||||
if (session == null) {
|
||||
return null;
|
||||
}
|
||||
return new SessionDescriptor(session);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,12 @@ public class SessionsEndpointWebIntegrationTests {
|
||||
.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
|
||||
protected static class TestConfiguration {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user