Skip to content

Commit

Permalink
UNDERTOW-1247 Incorrect behaviour of HttpSession.getLastAccessedTime()
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Dec 22, 2017
1 parent 5ec11dd commit dfa0f98
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public long getStartTime() {
private static class SessionImpl implements Session {


final AttachmentKey<Boolean> FIRST_REQUEST_ACCESS = AttachmentKey.create(Boolean.class);
final AttachmentKey<Long> FIRST_REQUEST_ACCESS = AttachmentKey.create(Long.class);
final InMemorySessionManager sessionManager;
final ConcurrentMap<String, Object> attributes = new ConcurrentHashMap<>();
volatile long lastAccessed;
Expand Down Expand Up @@ -457,17 +457,20 @@ public String getId() {
}

void requestStarted(HttpServerExchange serverExchange) {
Boolean existing = serverExchange.getAttachment(FIRST_REQUEST_ACCESS);
Long existing = serverExchange.getAttachment(FIRST_REQUEST_ACCESS);
if(existing == null) {
if (!invalid) {
lastAccessed = System.currentTimeMillis();
serverExchange.putAttachment(FIRST_REQUEST_ACCESS, System.currentTimeMillis());
}
serverExchange.putAttachment(FIRST_REQUEST_ACCESS, Boolean.TRUE);
}
}

@Override
public void requestDone(final HttpServerExchange serverExchange) {
Long existing = serverExchange.getAttachment(FIRST_REQUEST_ACCESS);
if(existing != null) {
lastAccessed = existing;
}
}

@Override
Expand Down

0 comments on commit dfa0f98

Please sign in to comment.