Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade WildFly to 28.0.0.Beta1 #108

Merged
merged 1 commit into from
Apr 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@
import org.wildfly.clustering.context.ContextClassLoaderReference;
import org.wildfly.clustering.context.ContextReferenceExecutor;
import org.wildfly.clustering.web.session.ImmutableSession;
import org.wildfly.clustering.web.session.SessionExpirationListener;

/**
* Invokes following timeout of a session.
* @author Paul Ferraro
*/
public class CatalinaSessionExpirationListener implements SessionExpirationListener {
public class CatalinaSessionExpirationListener implements Consumer<ImmutableSession> {

private final Consumer<ImmutableSession> expireAction;
private final Executor executor;
Expand All @@ -46,7 +45,7 @@ public CatalinaSessionExpirationListener(Context context) {
}

@Override
public void sessionExpired(ImmutableSession session) {
public void accept(ImmutableSession session) {
this.executor.execute(() -> this.expireAction.accept(session));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public long getLastAccessedTime() {

@Override
public int getMaxInactiveInterval() {
return (int) session.getMetaData().getMaxInactiveInterval().getSeconds();
return (int) session.getMetaData().getTimeout().getSeconds();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public Manager getManager() {
public int getMaxInactiveInterval() {
Session<LocalSessionContext> session = this.session.get();
try (BatchContext context = this.resumeBatch()) {
return (int) session.getMetaData().getMaxInactiveInterval().getSeconds();
return (int) session.getMetaData().getTimeout().getSeconds();
} catch (IllegalStateException e) {
this.closeIfInvalid(session);
throw e;
Expand Down Expand Up @@ -232,8 +232,8 @@ public void tellChangedSessionId(String newId, String oldId, boolean notifySessi
for (String name: oldSession.getAttributes().getAttributeNames()) {
newSession.getAttributes().setAttribute(name, oldSession.getAttributes().getAttribute(name));
}
newSession.getMetaData().setMaxInactiveInterval(oldSession.getMetaData().getMaxInactiveInterval());
newSession.getMetaData().setLastAccess(oldSession.getMetaData().getLastAccessStartTime(), oldSession.getMetaData().getLastAccessEndTime());
newSession.getMetaData().setMaxInactiveInterval(oldSession.getMetaData().getTimeout());
newSession.getMetaData().setLastAccess(oldSession.getMetaData().getLastAccessStartTime(), oldSession.getMetaData().getLastAccessTime());
newSession.getLocalContext().setAuthType(oldSession.getLocalContext().getAuthType());
newSession.getLocalContext().setPrincipal(oldSession.getLocalContext().getPrincipal());
oldSession.invalidate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public long getLastAccessedTime() {
public int getMaxInactiveInterval() {
Session<LocalSessionContext> session = this.session.get();
try (BatchContext context = this.manager.getSessionManager().getBatcher().resumeBatch(this.batch)) {
return (int) session.getMetaData().getMaxInactiveInterval().getSeconds();
return (int) session.getMetaData().getTimeout().getSeconds();
} catch (IllegalStateException e) {
this.closeIfInvalid.accept(session);
throw e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
import java.util.Optional;
import java.util.Properties;
import java.util.ServiceLoader;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.function.ToIntFunction;

import jakarta.servlet.ServletContext;
import jakarta.servlet.http.HttpSession;
Expand Down Expand Up @@ -72,9 +74,9 @@
import org.wildfly.clustering.web.LocalContextFactory;
import org.wildfly.clustering.web.hotrod.session.HotRodSessionManagerFactory;
import org.wildfly.clustering.web.hotrod.session.HotRodSessionManagerFactoryConfiguration;
import org.wildfly.clustering.web.session.ImmutableSession;
import org.wildfly.clustering.web.session.SessionAttributeImmutability;
import org.wildfly.clustering.web.session.SessionAttributePersistenceStrategy;
import org.wildfly.clustering.web.session.SessionExpirationListener;
import org.wildfly.clustering.web.session.SessionManager;
import org.wildfly.clustering.web.session.SessionManagerConfiguration;
import org.wildfly.clustering.web.session.SessionManagerFactory;
Expand All @@ -88,6 +90,8 @@
*/
public class HotRodManager extends ManagerBase {

static final ToIntFunction<ServletContext> SESSION_TIMEOUT_FUNCTION = ServletContext::getSessionTimeout;

private final Properties properties = new Properties();

private volatile RemoteCacheContainer container;
Expand Down Expand Up @@ -224,22 +228,27 @@ public SpecificationProvider<HttpSession, ServletContext, HttpSessionActivationL
this.managerFactory = new HotRodSessionManagerFactory<>(sessionManagerFactoryConfig);

ServletContext servletContext = context.getServletContext();
SessionExpirationListener expirationListener = new CatalinaSessionExpirationListener(context);
Consumer<ImmutableSession> expirationListener = new CatalinaSessionExpirationListener(context);
Supplier<String> identifierFactory = new CatalinaIdentifierFactory(this.getSessionIdGenerator());

SessionManagerConfiguration<ServletContext> sessionManagerConfiguration = new SessionManagerConfiguration<>() {
SessionManagerConfiguration<ServletContext> sessionManagerConfiguration = new org.wildfly.clustering.tomcat.SessionManagerConfiguration<>() {
@Override
public ServletContext getServletContext() {
return servletContext;
}

@Override
public ToIntFunction<ServletContext> getSessionTimeoutFunction() {
return SESSION_TIMEOUT_FUNCTION;
}

@Override
public Supplier<String> getIdentifierFactory() {
return identifierFactory;
}

@Override
public SessionExpirationListener getExpirationListener() {
public Consumer<ImmutableSession> getExpirationListener() {
return expirationListener;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@
import org.wildfly.clustering.context.ContextClassLoaderReference;
import org.wildfly.clustering.context.ContextReferenceExecutor;
import org.wildfly.clustering.web.session.ImmutableSession;
import org.wildfly.clustering.web.session.SessionExpirationListener;

/**
* Invokes following timeout of a session.
* @author Paul Ferraro
*/
public class CatalinaSessionExpirationListener implements SessionExpirationListener {
public class CatalinaSessionExpirationListener implements Consumer<ImmutableSession> {

private final Consumer<ImmutableSession> expireAction;
private final Executor executor;
Expand All @@ -46,7 +45,7 @@ public CatalinaSessionExpirationListener(Context context) {
}

@Override
public void sessionExpired(ImmutableSession session) {
public void accept(ImmutableSession session) {
this.executor.execute(() -> this.expireAction.accept(session));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public long getLastAccessedTime() {

@Override
public int getMaxInactiveInterval() {
return (int) session.getMetaData().getMaxInactiveInterval().getSeconds();
return (int) session.getMetaData().getTimeout().getSeconds();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public Manager getManager() {
public int getMaxInactiveInterval() {
Session<LocalSessionContext> session = this.session.get();
try (BatchContext context = this.resumeBatch()) {
return (int) session.getMetaData().getMaxInactiveInterval().getSeconds();
return (int) session.getMetaData().getTimeout().getSeconds();
} catch (IllegalStateException e) {
this.closeIfInvalid(session);
throw e;
Expand Down Expand Up @@ -232,8 +232,8 @@ public void tellChangedSessionId(String newId, String oldId, boolean notifySessi
for (String name: oldSession.getAttributes().getAttributeNames()) {
newSession.getAttributes().setAttribute(name, oldSession.getAttributes().getAttribute(name));
}
newSession.getMetaData().setMaxInactiveInterval(oldSession.getMetaData().getMaxInactiveInterval());
newSession.getMetaData().setLastAccess(oldSession.getMetaData().getLastAccessStartTime(), oldSession.getMetaData().getLastAccessEndTime());
newSession.getMetaData().setMaxInactiveInterval(oldSession.getMetaData().getTimeout());
newSession.getMetaData().setLastAccess(oldSession.getMetaData().getLastAccessStartTime(), oldSession.getMetaData().getLastAccessTime());
newSession.getLocalContext().setAuthType(oldSession.getLocalContext().getAuthType());
newSession.getLocalContext().setPrincipal(oldSession.getLocalContext().getPrincipal());
oldSession.invalidate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public long getLastAccessedTime() {
public int getMaxInactiveInterval() {
Session<LocalSessionContext> session = this.session.get();
try (BatchContext context = this.manager.getSessionManager().getBatcher().resumeBatch(this.batch)) {
return (int) session.getMetaData().getMaxInactiveInterval().getSeconds();
return (int) session.getMetaData().getTimeout().getSeconds();
} catch (IllegalStateException e) {
this.closeIfInvalid.accept(session);
throw e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
import java.util.Optional;
import java.util.Properties;
import java.util.ServiceLoader;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.function.ToIntFunction;

import jakarta.servlet.ServletContext;
import jakarta.servlet.http.HttpSession;
Expand Down Expand Up @@ -72,9 +74,9 @@
import org.wildfly.clustering.web.LocalContextFactory;
import org.wildfly.clustering.web.hotrod.session.HotRodSessionManagerFactory;
import org.wildfly.clustering.web.hotrod.session.HotRodSessionManagerFactoryConfiguration;
import org.wildfly.clustering.web.session.ImmutableSession;
import org.wildfly.clustering.web.session.SessionAttributeImmutability;
import org.wildfly.clustering.web.session.SessionAttributePersistenceStrategy;
import org.wildfly.clustering.web.session.SessionExpirationListener;
import org.wildfly.clustering.web.session.SessionManager;
import org.wildfly.clustering.web.session.SessionManagerConfiguration;
import org.wildfly.clustering.web.session.SessionManagerFactory;
Expand All @@ -88,6 +90,8 @@
*/
public class HotRodManager extends ManagerBase {

static final ToIntFunction<ServletContext> SESSION_TIMEOUT_FUNCTION = ServletContext::getSessionTimeout;

private final Properties properties = new Properties();

private volatile RemoteCacheContainer container;
Expand Down Expand Up @@ -224,22 +228,27 @@ public SpecificationProvider<HttpSession, ServletContext, HttpSessionActivationL
this.managerFactory = new HotRodSessionManagerFactory<>(sessionManagerFactoryConfig);

ServletContext servletContext = context.getServletContext();
SessionExpirationListener expirationListener = new CatalinaSessionExpirationListener(context);
Consumer<ImmutableSession> expirationListener = new CatalinaSessionExpirationListener(context);
Supplier<String> identifierFactory = new CatalinaIdentifierFactory(this.getSessionIdGenerator());

SessionManagerConfiguration<ServletContext> sessionManagerConfiguration = new SessionManagerConfiguration<>() {
SessionManagerConfiguration<ServletContext> sessionManagerConfiguration = new org.wildfly.clustering.tomcat.SessionManagerConfiguration<>() {
@Override
public ServletContext getServletContext() {
return servletContext;
}

@Override
public ToIntFunction<ServletContext> getSessionTimeoutFunction() {
return SESSION_TIMEOUT_FUNCTION;
}

@Override
public Supplier<String> getIdentifierFactory() {
return identifierFactory;
}

@Override
public SessionExpirationListener getExpirationListener() {
public Consumer<ImmutableSession> getExpirationListener() {
return expirationListener;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@
import org.wildfly.clustering.context.ContextClassLoaderReference;
import org.wildfly.clustering.context.ContextReferenceExecutor;
import org.wildfly.clustering.web.session.ImmutableSession;
import org.wildfly.clustering.web.session.SessionExpirationListener;

/**
* Invokes following timeout of a session.
* @author Paul Ferraro
*/
public class CatalinaSessionExpirationListener implements SessionExpirationListener {
public class CatalinaSessionExpirationListener implements Consumer<ImmutableSession> {

private final Consumer<ImmutableSession> expireAction;
private final Executor executor;
Expand All @@ -46,7 +45,7 @@ public CatalinaSessionExpirationListener(Context context) {
}

@Override
public void sessionExpired(ImmutableSession session) {
public void accept(ImmutableSession session) {
this.executor.execute(() -> this.expireAction.accept(session));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public long getLastAccessedTime() {

@Override
public int getMaxInactiveInterval() {
return (int) session.getMetaData().getMaxInactiveInterval().getSeconds();
return (int) session.getMetaData().getTimeout().getSeconds();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public Manager getManager() {
public int getMaxInactiveInterval() {
Session<LocalSessionContext> session = this.session.get();
try (BatchContext context = this.resumeBatch()) {
return (int) session.getMetaData().getMaxInactiveInterval().getSeconds();
return (int) session.getMetaData().getTimeout().getSeconds();
} catch (IllegalStateException e) {
this.closeIfInvalid(session);
throw e;
Expand Down Expand Up @@ -232,8 +232,8 @@ public void tellChangedSessionId(String newId, String oldId, boolean notifySessi
for (String name: oldSession.getAttributes().getAttributeNames()) {
newSession.getAttributes().setAttribute(name, oldSession.getAttributes().getAttribute(name));
}
newSession.getMetaData().setMaxInactiveInterval(oldSession.getMetaData().getMaxInactiveInterval());
newSession.getMetaData().setLastAccess(oldSession.getMetaData().getLastAccessStartTime(), oldSession.getMetaData().getLastAccessEndTime());
newSession.getMetaData().setMaxInactiveInterval(oldSession.getMetaData().getTimeout());
newSession.getMetaData().setLastAccess(oldSession.getMetaData().getLastAccessStartTime(), oldSession.getMetaData().getLastAccessTime());
newSession.getLocalContext().setAuthType(oldSession.getLocalContext().getAuthType());
newSession.getLocalContext().setPrincipal(oldSession.getLocalContext().getPrincipal());
oldSession.invalidate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public long getLastAccessedTime() {
public int getMaxInactiveInterval() {
Session<LocalSessionContext> session = this.session.get();
try (BatchContext context = this.manager.getSessionManager().getBatcher().resumeBatch(this.batch)) {
return (int) session.getMetaData().getMaxInactiveInterval().getSeconds();
return (int) session.getMetaData().getTimeout().getSeconds();
} catch (IllegalStateException e) {
this.closeIfInvalid.accept(session);
throw e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@

import java.io.IOException;
import java.net.URI;
import java.time.Duration;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.Properties;
import java.util.ServiceLoader;
import java.util.function.Consumer;
import java.util.function.Supplier;

import javax.servlet.ServletContext;
Expand Down Expand Up @@ -72,9 +74,9 @@
import org.wildfly.clustering.web.LocalContextFactory;
import org.wildfly.clustering.web.hotrod.session.HotRodSessionManagerFactory;
import org.wildfly.clustering.web.hotrod.session.HotRodSessionManagerFactoryConfiguration;
import org.wildfly.clustering.web.session.ImmutableSession;
import org.wildfly.clustering.web.session.SessionAttributeImmutability;
import org.wildfly.clustering.web.session.SessionAttributePersistenceStrategy;
import org.wildfly.clustering.web.session.SessionExpirationListener;
import org.wildfly.clustering.web.session.SessionManager;
import org.wildfly.clustering.web.session.SessionManagerConfiguration;
import org.wildfly.clustering.web.session.SessionManagerFactory;
Expand Down Expand Up @@ -224,7 +226,7 @@ public SpecificationProvider<HttpSession, ServletContext, HttpSessionActivationL
this.managerFactory = new HotRodSessionManagerFactory<>(sessionManagerFactoryConfig);

ServletContext servletContext = context.getServletContext();
SessionExpirationListener expirationListener = new CatalinaSessionExpirationListener(context);
Consumer<ImmutableSession> expirationListener = new CatalinaSessionExpirationListener(context);
Supplier<String> identifierFactory = new CatalinaIdentifierFactory(this.getSessionIdGenerator());

SessionManagerConfiguration<ServletContext> sessionManagerConfiguration = new SessionManagerConfiguration<>() {
Expand All @@ -233,13 +235,18 @@ public ServletContext getServletContext() {
return servletContext;
}

@Override
public Duration getTimeout() {
return Duration.ofMinutes(context.getSessionTimeout());
}

@Override
public Supplier<String> getIdentifierFactory() {
return identifierFactory;
}

@Override
public SessionExpirationListener getExpirationListener() {
public Consumer<ImmutableSession> getExpirationListener() {
return expirationListener;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@
import org.wildfly.clustering.context.ContextClassLoaderReference;
import org.wildfly.clustering.context.ContextReferenceExecutor;
import org.wildfly.clustering.web.session.ImmutableSession;
import org.wildfly.clustering.web.session.SessionExpirationListener;

/**
* Invokes following timeout of a session.
* @author Paul Ferraro
*/
public class CatalinaSessionExpirationListener implements SessionExpirationListener {
public class CatalinaSessionExpirationListener implements Consumer<ImmutableSession> {

private final Consumer<ImmutableSession> expireAction;
private final Executor executor;
Expand All @@ -46,7 +45,7 @@ public CatalinaSessionExpirationListener(Context context) {
}

@Override
public void sessionExpired(ImmutableSession session) {
public void accept(ImmutableSession session) {
this.executor.execute(() -> this.expireAction.accept(session));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public long getLastAccessedTime() {

@Override
public int getMaxInactiveInterval() {
return (int) session.getMetaData().getMaxInactiveInterval().getSeconds();
return (int) session.getMetaData().getTimeout().getSeconds();
}

@Override
Expand Down
Loading