This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new a9aba6d211 ISIS-3174: wkt session logging: fixes case when no session
yet
a9aba6d211 is described below
commit a9aba6d2118ab483c30721b3ad0bfb763178765d
Author: Andi Huber <[email protected]>
AuthorDate: Thu Aug 25 08:56:23 2022 +0200
ISIS-3174: wkt session logging: fixes case when no session yet
---
.../AuthenticatedWebSessionForIsis.java | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git
a/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/AuthenticatedWebSessionForIsis.java
b/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/AuthenticatedWebSessionForIsis.java
index e23eb59ae8..742f5cf895 100644
---
a/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/AuthenticatedWebSessionForIsis.java
+++
b/viewers/wicket/viewer/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/AuthenticatedWebSessionForIsis.java
@@ -86,11 +86,18 @@ implements
private UUID sessionGuid;
private String cachedSessionId;
- public String getCachedSessionId() {
- if (cachedSessionId == null && Session.exists()) {
+ /**
+ * Optionally the current HttpSession's Id,
+ * based on whether such a session is available.
+ * @implNote side-effect free, that is,
+ * must not create a session if there is none yet
+ */
+ public Optional<String> getCachedSessionId() {
+ if (cachedSessionId == null
+ && Session.exists()) {
cachedSessionId = getId();
}
- return cachedSessionId;
+ return Optional.ofNullable(cachedSessionId);
}
public AuthenticatedWebSessionForIsis(final Request request) {
@@ -252,11 +259,12 @@ implements
final Runnable loggingTask = ()->{
val now = virtualClock().nowAsJavaUtilDate();
+ val httpSessionId =
AuthenticatedWebSessionForIsis.this.getCachedSessionId()
+ .orElse("(none)");
- String httpSessionId =
AuthenticatedWebSessionForIsis.this.getCachedSessionId();
- sessionLoggingServices.forEach(sessionLoggingService ->
- sessionLoggingService.log(type, username, now, causedBy,
getSessionGuid(), httpSessionId)
- );
+ sessionLoggingServices
+ .forEach(sessionLoggingService ->
+ sessionLoggingService.log(type, username, now, causedBy,
getSessionGuid(), httpSessionId));
};
if(interactionService!=null) {