Copilot commented on code in PR #2712:
URL: https://github.com/apache/shiro/pull/2712#discussion_r3293846788
##########
core/src/main/java/org/apache/shiro/session/mgt/SimpleSession.java:
##########
@@ -451,17 +458,17 @@ private void writeObject(ObjectOutputStream out) throws
IOException {
if (startTimestamp != null) {
out.writeObject(startTimestamp);
}
- if (stopTimestamp != null) {
- out.writeObject(stopTimestamp);
+ if (stopTimestamp.get() != null) {
+ out.writeObject(stopTimestamp.get());
}
- if (lastAccessTime != null) {
- out.writeObject(lastAccessTime);
+ if (lastAccessTime.get() != null) {
+ out.writeObject(lastAccessTime.get());
}
- if (timeout != 0L) {
- out.writeLong(timeout);
+ if (timeout.get() != 0L) {
+ out.writeLong(timeout.get());
}
- if (expired) {
- out.writeBoolean(expired);
+ if (expired.get()) {
+ out.writeBoolean(expired.get());
Review Comment:
writeObject calls stopTimestamp.get() / lastAccessTime.get() / timeout.get()
multiple times (and expired.get() twice). Under concurrent updates this can
lead to an inconsistent serialized representation (e.g., bitmask computed for
one value but a different value written). Capture each atomic value into a
local variable once and use that consistently for both null checks and writes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]