Skip to content

Commit

Permalink
FELIX-5819 : Container session should not be invalidated
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1827956 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
cziegeler committed Mar 29, 2018
1 parent 49fb461 commit f86428f
Showing 1 changed file with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,31 +148,33 @@ public HttpSessionWrapper(final HttpSession session,
this.delegate = session;
this.context = context;
this.sessionId = context.getServletContextName();
this.keyPrefix = ATTR_PREFIX + this.sessionId + ".";
this.keyPrefix = ATTR_PREFIX.concat(this.sessionId).concat(".");

final String createdAttrName = ATTR_CREATED.concat(this.sessionId);

final long now = System.currentTimeMillis();
if ( session.getAttribute(ATTR_CREATED + this.sessionId) == null )
if ( session.getAttribute(createdAttrName) == null )
{
this.created = now;
this.maxTimeout = session.getMaxInactiveInterval();
this.isNew = true;

session.setAttribute(ATTR_CREATED + this.sessionId, this.created);
session.setAttribute(ATTR_MAX_INACTIVE + this.sessionId, this.maxTimeout);
session.setAttribute(createdAttrName, this.created);
session.setAttribute(ATTR_MAX_INACTIVE.concat(this.sessionId), this.maxTimeout);

context.getHttpSessionListener().sessionCreated(new HttpSessionEvent(this));
}
else
{
this.created = (Long)session.getAttribute(ATTR_CREATED + this.sessionId);
this.maxTimeout = (Integer)session.getAttribute(ATTR_MAX_INACTIVE + this.sessionId);
this.created = (Long)session.getAttribute(createdAttrName);
this.maxTimeout = (Integer)session.getAttribute(ATTR_MAX_INACTIVE.concat(this.sessionId));
this.isNew = false;
}

this.lastAccessed = now;
if ( !terminate )
{
session.setAttribute(ATTR_LAST_ACCESSED + this.sessionId, this.lastAccessed);
session.setAttribute(ATTR_LAST_ACCESSED.concat(this.sessionId), this.lastAccessed);
}
}

Expand Down Expand Up @@ -314,6 +316,7 @@ public void invalidate()
this.delegate.removeAttribute(ATTR_LAST_ACCESSED + this.sessionId);
this.delegate.removeAttribute(ATTR_MAX_INACTIVE + this.sessionId);

// remove all attributes belonging to this session
final Enumeration<String> names = this.delegate.getAttributeNames();
while ( names.hasMoreElements() )
{
Expand All @@ -324,12 +327,6 @@ public void invalidate()
}
}

// if the session is empty we can invalidate
if ( !this.delegate.getAttributeNames().hasMoreElements() )
{
this.delegate.invalidate();
}

this.isInvalid = true;
}

Expand Down

0 comments on commit f86428f

Please sign in to comment.