-
Notifications
You must be signed in to change notification settings - Fork 41.3k
Add actuator endpoint for finding and deleting sessions #8342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
b82bfd9
to
8e9ce60
Compare
8e9ce60
to
297e675
Compare
297e675
to
c8599f7
Compare
d0e19a7
to
ff4d0f6
Compare
I've adapted this PR to the new Actuator endpoint infrastructure. Hands-on developer experience with the new stuff is just great! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @vpavic!
I've made a few suggestions (which might lead us to add another extension point in the Endpoint API).
Also, I wonder if a sample wouldn't be in order for this? This can happen in a separate PR for sure.
@ReadOperation | ||
public WebEndpointResponse<SessionsReport> sessionsForUsername(String username) { | ||
if (username == null) { | ||
return new WebEndpointResponse<>(HttpStatus.BAD_REQUEST.value()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't use HttpStatus
here as this class may not be available when running with Jersey. That's why that object is taking the raw int
code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Web framework neutrality completely slipped my mind when using HttpStatus
, I'll address that shortly.
Note that I used the same pattern in AuditEventsWebEndpointExtension
that was introduced in #10322. Quick search also revealed another usage in HeapDumpWebEndpoint
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback. I've created #10348
|
||
@Test | ||
public void deleteSession() { | ||
this.endpoint.deleteSession(session.getId()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That test does nothing. Verify that the repository was called with the right argument would be in order:
verify(this.repository).deleteById(session.getId());
@@ -106,6 +106,10 @@ The following technology agnostic endpoints are available: | |||
|`mappings` | |||
|Displays a collated list of all `@RequestMapping` paths. | |||
|
|||
|`sessions` | |||
|Allows retrieving user's sessions from Spring Session backed session store, and deleting | |||
them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add that to the first part of the sentence (see above for an example).
ff4d0f6
to
d007994
Compare
Thanks for the review @snicoll, I've addressed your concerns. Regarding the sample remark, would it be OK to reuse the existing |
d007994
to
07b72a6
Compare
Yes. Perhaps we could first rename it and use something else. jdbc comes to mind even I know you guys don't want to promote it too much? That sample looks outdated as it requires a redis server. |
Can we use the similar approach to one in |
Maybe. Not sure that's an immediate goal but I am happy to review a PR |
07b72a6
to
49348ef
Compare
49348ef
to
661f9ca
Compare
I've updated the PR to adopt to changes from #10350 and enable the new endpoint in |
Transient errors involving
|
We see those on Bamboo too. @bclozel has been investigating. My suspicion is that it's a Linux-specific problem in Netty or Reactor Netty. |
Thanks for the feedback. FWIW I didn't hit those problems on Ubuntu 17.04. |
* pr/8342: Polish "Add actuator endpoint for finding and deleting sessions" Add actuator endpoint for finding and deleting sessions
@vpavic was there a reason that the endpoint doesn't have the option of returning the IDs of all sessions within the repository? |
There's no support in Spring Session for getting the IDs of all sessions known to the repository. |
This PR is an alternative approach to implementing sessions endpoint to one proposed in #5730.
Key differences:
Endpoint
implementation i.e. it only provides MVC and JMX endpoints that simply delegate to Spring Session'sFindByIndexNameSessionRepository
(this is analogous to audit events endpoints - see Add actuator endpoint to retrieve audit events #6579)JmxEndpoint
implementations without a backingEndpoint
(introduced in Add actuator endpoint to retrieve audit events #6579)