use of org.wildfly.clustering.web.session.Session in project wildfly by wildfly.
the class DistributableSession method invalidate.
@Override
public void invalidate(HttpServerExchange exchange) {
Map.Entry<Session<Map<String, Object>>, SessionConfig> entry = this.getSessionEntry();
@SuppressWarnings("resource") Session<Map<String, Object>> session = entry.getKey();
if (session.isValid()) {
// Invoke listeners outside of the context of the batch associated with this session
// Trigger attribute listeners
this.manager.getSessionListeners().sessionDestroyed(this, exchange, SessionDestroyedReason.INVALIDATED);
ImmutableSessionAttributes attributes = session.getAttributes();
for (String name : attributes.getAttributeNames()) {
Object value = attributes.getAttribute(name);
this.manager.getSessionListeners().attributeRemoved(this, name, value);
}
}
try (BatchContext context = this.resumeBatch()) {
session.invalidate();
if (exchange != null) {
String id = session.getId();
entry.getValue().clearSession(exchange, id);
}
// An OOB session has no batch
if (this.batch != null) {
this.batch.close();
}
} catch (IllegalStateException e) {
// If Session.invalidate() fails due to concurrent invalidation, close this session
if (!session.isValid()) {
session.close();
}
throw e;
} finally {
this.closeTask.accept(exchange);
}
}
Aggregations