Commit a7fac3cb authored by Stephane Nicoll's avatar Stephane Nicoll

Merge pull request #11202 from ptahchiev:11201

* pr/11202:
  Polish "Fix NullPointer when requesting a session that does not exist"
  Fix NullPointer when requesting a session that does not exist
parents 6cae9257 b6609ff3
......@@ -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);
}
......
......@@ -81,6 +81,12 @@ public class SessionsEndpointTests {
assertThat(result.isExpired()).isEqualTo(session.isExpired());
}
@Test
public void getSessionWithIdNotFound() {
given(this.repository.findById("not-found")).willReturn(null);
assertThat(this.endpoint.getSession("not-found")).isNull();
}
@Test
public void deleteSession() {
this.endpoint.deleteSession(session.getId());
......
......@@ -80,6 +80,14 @@ public class SessionsEndpointWebIntegrationTests {
.isEqualTo(new JSONArray().appendElement(session.getId()));
}
@Test
public void sessionForIdNotFound() {
client.get()
.uri((builder) -> builder.path(
"/actuator/sessions/session-id-not-found").build())
.exchange().expectStatus().isNotFound();
}
@Configuration
protected static class TestConfiguration {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment