Skip to content

Added SQL analysis example to Spring Session - #814

Open
TomaszGaweda wants to merge 3 commits into
hazelcast:masterfrom
TomaszGaweda:resilient-sessions-sql
Open

TomaszGaweda wants to merge 3 commits into
hazelcast:masterfrom
TomaszGaweda:resilient-sessions-sql

Conversation

@TomaszGaweda

Copy link
Copy Markdown
Contributor

Added SQL analysis example to Spring Session to be used with blog post.,


<properties>
<hazelcast.version>5.6.0</hazelcast.version>
<hazelcast.version>5.7.0</hazelcast.version>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this inherit from parent to avoid hardcoding?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

various samples use different versions though

jet:
enabled: true
resource-upload-enabled: true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

nit consistency with other config.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +57 to +59
Instant lastAccessedTime = s.getLastAccessedTime();
Duration howLongInactive = Duration.between(lastAccessedTime, Instant.now());
String timeStatus = howLongInactive.compareTo(MAX_INACTIVE_DURATION) > 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Instant lastAccessedTime = s.getLastAccessedTime();
Duration howLongInactive = Duration.between(lastAccessedTime, Instant.now());
String timeStatus = howLongInactive.compareTo(MAX_INACTIVE_DURATION) > 0
String timeStatus = Instant.now().isAfter(s.getLastAccessedTime().plus(MAX_INACTIVE_DURATION))

existing functionality, but more readable

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +32 to +33
LocalDateTime timestamp = lastAccessedTime == null ? null
: LocalDateTime.ofInstant(Instant.ofEpochMilli(lastAccessedTime.getTime()), ZoneOffset.UTC);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

serializing localdatetimes sounds potentially problematic - why not as instants?

@TomaszGaweda TomaszGaweda Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no particular reason tbh - just an example. There is no method with Instant as parameter, so either LocalDate or LocalDateTime

}
}

private static String formatSqlResult(SqlResult result) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there not some library we can use for this formatting instead?

Also, \n -> System.lineSeperator().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think of removing it at all. Quite a bad code to show, right? 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants