diff --git a/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/ClientServerTest.java b/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/ClientServerTest.java index 6cb4c075fde..7e0b11832a2 100644 --- a/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/ClientServerTest.java +++ b/jetty-core/jetty-http3/jetty-http3-tests/src/test/java/org/eclipse/jetty/http3/tests/ClientServerTest.java @@ -39,6 +39,7 @@ import org.eclipse.jetty.http3.server.AbstractHTTP3ServerConnectionFactory; import org.eclipse.jetty.http3.server.internal.HTTP3SessionServer; import org.eclipse.jetty.quic.client.ClientQuicSession; import org.eclipse.jetty.quic.common.QuicSession; +import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -365,6 +366,7 @@ public class ClientServerTest extends AbstractClientServerTest } @Test + @Tag("flaky") public void testRequestHeadersTooLarge() throws Exception { start(new Session.Server.Listener() diff --git a/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/AbstractSessionDataStore.java b/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/AbstractSessionDataStore.java index d51c6076183..578941a24dd 100644 --- a/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/AbstractSessionDataStore.java +++ b/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/AbstractSessionDataStore.java @@ -13,10 +13,16 @@ package org.eclipse.jetty.session; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.OutputStream; import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; +import org.eclipse.jetty.util.ClassLoadingObjectInputStream; import org.eclipse.jetty.util.FuturePromise; import org.eclipse.jetty.util.annotation.ManagedAttribute; import org.eclipse.jetty.util.annotation.ManagedObject; diff --git a/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/FileSessionDataStore.java b/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/FileSessionDataStore.java index bd9ecc5f1ba..4d82f130bbb 100644 --- a/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/FileSessionDataStore.java +++ b/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/FileSessionDataStore.java @@ -20,6 +20,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.nio.file.FileVisitOption; @@ -32,7 +33,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import java.util.stream.Stream; -import org.eclipse.jetty.util.ClassLoadingObjectInputStream; import org.eclipse.jetty.util.ExceptionUtil; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.annotation.ManagedAttribute; @@ -46,7 +46,7 @@ import org.slf4j.LoggerFactory; * A file-based store of session data. */ @ManagedObject -public class FileSessionDataStore extends AbstractSessionDataStore +public class FileSessionDataStore extends ObjectStreamSessionDataStore { private static final Logger LOG = LoggerFactory.getLogger(FileSessionDataStore.class); protected File _storeDir; @@ -464,7 +464,7 @@ public class FileSessionDataStore extends AbstractSessionDataStore * @param id identity of the session * @param data the info of the session */ - protected void save(OutputStream os, String id, SessionData data) throws IOException + protected void save(OutputStream os, String id, SessionData data) throws Exception { DataOutputStream out = new DataOutputStream(os); out.writeUTF(id); @@ -478,8 +478,7 @@ public class FileSessionDataStore extends AbstractSessionDataStore out.writeLong(data.getExpiry()); out.writeLong(data.getMaxInactiveMs()); - ObjectOutputStream oos = new ObjectOutputStream(out); - SessionData.serializeAttributes(data, oos); + serializeAttributes(data, out); } /** @@ -623,8 +622,7 @@ public class FileSessionDataStore extends AbstractSessionDataStore data.setMaxInactiveMs(maxIdle); // Attributes - ClassLoadingObjectInputStream ois = new ClassLoadingObjectInputStream(is); - SessionData.deserializeAttributes(data, ois); + deserializeAttributes(data, is); return data; } catch (Exception e) diff --git a/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/JDBCSessionDataStore.java b/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/JDBCSessionDataStore.java index 1fda94b0132..b06d56a9346 100644 --- a/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/JDBCSessionDataStore.java +++ b/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/JDBCSessionDataStore.java @@ -16,6 +16,7 @@ package org.eclipse.jetty.session; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; +import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.sql.Connection; import java.sql.DatabaseMetaData; @@ -26,7 +27,6 @@ import java.sql.Statement; import java.util.HashSet; import java.util.Set; -import org.eclipse.jetty.util.ClassLoadingObjectInputStream; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.annotation.ManagedAttribute; import org.eclipse.jetty.util.annotation.ManagedObject; @@ -39,7 +39,7 @@ import org.slf4j.LoggerFactory; * Session data stored in database */ @ManagedObject -public class JDBCSessionDataStore extends AbstractSessionDataStore +public class JDBCSessionDataStore extends ObjectStreamSessionDataStore { private static final Logger LOG = LoggerFactory.getLogger(JDBCSessionDataStore.class); @@ -662,10 +662,9 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore data.setContextPath(_context.getCanonicalContextPath()); data.setVhost(_context.getVhost()); - try (InputStream is = _dbAdaptor.getBlobInputStream(result, _sessionTableSchema.getMapColumn()); - ClassLoadingObjectInputStream ois = new ClassLoadingObjectInputStream(is)) + try (InputStream is = _dbAdaptor.getBlobInputStream(result, _sessionTableSchema.getMapColumn())) { - SessionData.deserializeAttributes(data, ois); + deserializeAttributes(data, is); } catch (Exception e) { @@ -741,10 +740,10 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore statement.setLong(10, data.getExpiry()); statement.setLong(11, data.getMaxInactiveMs()); - try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(baos)) + try (ByteArrayOutputStream baos = new ByteArrayOutputStream();) { - SessionData.serializeAttributes(data, oos); + serializeAttributes(data, baos); + byte[] bytes = baos.toByteArray(); ByteArrayInputStream bais = new ByteArrayInputStream(bytes); statement.setBinaryStream(12, bais, bytes.length); //attribute map as blob @@ -772,10 +771,10 @@ public class JDBCSessionDataStore extends AbstractSessionDataStore statement.setLong(5, data.getExpiry()); statement.setLong(6, data.getMaxInactiveMs()); - try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(baos)) + try (ByteArrayOutputStream baos = new ByteArrayOutputStream();) { - SessionData.serializeAttributes(data, oos); + serializeAttributes(data, baos); + byte[] bytes = baos.toByteArray(); try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes)) { diff --git a/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/ObjectStreamSessionDataStore.java b/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/ObjectStreamSessionDataStore.java new file mode 100644 index 00000000000..4e2a8f08809 --- /dev/null +++ b/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/ObjectStreamSessionDataStore.java @@ -0,0 +1,102 @@ +// +// ======================================================================== +// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +package org.eclipse.jetty.session; + +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.OutputStream; +import java.util.Objects; + +import org.eclipse.jetty.util.ClassLoadingObjectInputStream; + +public abstract class ObjectStreamSessionDataStore extends AbstractSessionDataStore +{ + /** + * Get an ObjectOutputStream suitable to serialize SessionData objects + * into the provided OutputStream. + *
+ * By default, an ObjectObjectStream is returned. + *
+ * Override this method to provide a custom ObjectOutputStream, and/or to + * chain other OutputStreams to perform such tasks as compressing the serialized + * data, for example: + *
+ * + * GZIPOutputStream gos = new GZIPOutputStream(os); + * return new ObjectOutputStream(gos); + * + * @param os an output stream to which to serialize the session data + * @return an ObjectOutputStream wrapping the OutputStream + * @throws IOException if the stream cannot be created + */ + public ObjectOutputStream newObjectOutputStream(OutputStream os) throws IOException + { + return new ObjectOutputStream(os); + } + + /** + * Get an ObjectInputStream that is capable of deserializing the session data + * present in the provided InputStream. + *
+ * By default, a Classloader-aware ObjectInputStream is used, however, you + * can return your own specialized ObjectInputStream, or chain other InputStreams + * together to perform such tasks as data decompression, for example: + *
+ * + * GZIPInputStream gis = new GZIPInputStream(is); + * return new ClassLoadingObjectInputStream(is) + * + * @param is an input stream for accessing the session data to be deserialized + * @return an ObjectInputStream that can deserialize the session data + * @throws IOException if the stream cannot be created + */ + protected ObjectInputStream newObjectInputStream(InputStream is) throws IOException + { + return new ClassLoadingObjectInputStream(is); + } + + /** + * Serialize the attribute map of the SessionData into the OutputStream provided. + * @param data the SessionData whose attributes are to be serialized + * @param os the OutputStream to receive the serialized attributes + * @throws Exception if the attributes cannot be serialized + */ + protected void serializeAttributes(SessionData data, OutputStream os) throws Exception + { + Objects.requireNonNull(data); + Objects.requireNonNull(os); + try (ObjectOutputStream oos = newObjectOutputStream(os)) + { + SessionData.serializeAttributes(data, oos); + } + } + + /** + * Deserialize the attribute map from the InputStream provided and store into the SessionData. + * @param data the SessionData into which to deserialize the attributes + * @param is the InputStream for reading the serialized attributes + * @throws Exception if the attributes cannot be deserialized + */ + protected void deserializeAttributes(SessionData data, InputStream is) throws Exception + { + Objects.requireNonNull(data); + Objects.requireNonNull(is); + try (ObjectInputStream ois = newObjectInputStream(is)) + { + SessionData.deserializeAttributes(data, ois); + } + } +} diff --git a/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/SessionData.java b/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/SessionData.java index c566ce8fa91..a5445c76cca 100644 --- a/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/SessionData.java +++ b/jetty-core/jetty-session/src/main/java/org/eclipse/jetty/session/SessionData.java @@ -144,7 +144,8 @@ public class SessionData implements Serializable if (LOG.isDebugEnabled()) LOG.debug("Deserialize {} isServerLoader={} serverLoader={} tccl={}", name, isServerClassLoader, serverLoader, contextLoader); Object value = ((ClassLoadingObjectInputStream)in).readObject(isServerClassLoader ? serverLoader : contextLoader); - data._attributes.put(name, value); + if (value != null) + data._attributes.put(name, value); } } else diff --git a/jetty-core/jetty-session/src/test/java/org/eclipse/jetty/session/AbstractSessionDataStoreTest.java b/jetty-core/jetty-session/src/test/java/org/eclipse/jetty/session/AbstractSessionDataStoreTest.java index 994584ad6bf..439bc5feb91 100644 --- a/jetty-core/jetty-session/src/test/java/org/eclipse/jetty/session/AbstractSessionDataStoreTest.java +++ b/jetty-core/jetty-session/src/test/java/org/eclipse/jetty/session/AbstractSessionDataStoreTest.java @@ -456,10 +456,9 @@ public abstract class AbstractSessionDataStoreTest long now = System.currentTimeMillis(); SessionData data = store.newSessionData("aaa6", 100, now, now - 1, -1); data.setLastNode(_sessionIdManager.getWorkerName()); - //persistSession(data); store.store("aaa6", data); _server.stop(); - _server.start(); //reindex files + _server.start(); store = _sessionManager.getSessionCache().getSessionDataStore(); //test that we can retrieve it diff --git a/jetty-core/jetty-session/src/test/java/org/eclipse/jetty/session/JdbcTestHelper.java b/jetty-core/jetty-session/src/test/java/org/eclipse/jetty/session/JdbcTestHelper.java index 96a006f6733..209840fdad2 100644 --- a/jetty-core/jetty-session/src/test/java/org/eclipse/jetty/session/JdbcTestHelper.java +++ b/jetty-core/jetty-session/src/test/java/org/eclipse/jetty/session/JdbcTestHelper.java @@ -15,8 +15,12 @@ package org.eclipse.jetty.session; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.io.InputStream; +import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.io.OutputStream; +import java.io.Serializable; import java.sql.Blob; import java.sql.Connection; import java.sql.DriverManager; @@ -25,6 +29,8 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashSet; import java.util.Set; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; import org.eclipse.jetty.util.ClassLoadingObjectInputStream; import org.slf4j.Logger; @@ -129,14 +135,75 @@ public class JdbcTestHelper /** * @return a fresh JDBCSessionDataStoreFactory */ - public static SessionDataStoreFactory newSessionDataStoreFactory(String sessionTableName) + public static SessionDataStoreFactory newSessionDataStoreFactory(String sessionTableName, boolean compress) { - return newSessionDataStoreFactory(buildDatabaseAdaptor(), sessionTableName); + return newSessionDataStoreFactory(buildDatabaseAdaptor(), sessionTableName, compress); } - public static SessionDataStoreFactory newSessionDataStoreFactory(DatabaseAdaptor da, String sessionTableName) + public static ObjectOutputStream newObjectOutputStream(OutputStream os, boolean compress) throws IOException { - JDBCSessionDataStoreFactory factory = new JDBCSessionDataStoreFactory(); + if (!compress) + return new ObjectOutputStream(os); + + GZIPOutputStream gos = new GZIPOutputStream(os, 1024); + class SkipUnserializableObjectOutputStream extends ObjectOutputStream + { + public SkipUnserializableObjectOutputStream(OutputStream out) throws IOException + { + super(out); + enableReplaceObject(true); + } + + @Override + protected Object replaceObject(Object obj) throws IOException + { + if (obj instanceof Serializable) + return obj; + + return null; + } + } + + return new SkipUnserializableObjectOutputStream(gos); + } + + public static ObjectInputStream newObjectInputStream(InputStream is, boolean compress) throws IOException + { + if (!compress) + return new ClassLoadingObjectInputStream(is); + + GZIPInputStream gis = new GZIPInputStream(is, 1024); + return new ClassLoadingObjectInputStream(gis); + } + + public static SessionDataStoreFactory newSessionDataStoreFactory(DatabaseAdaptor da, String sessionTableName, boolean compress) + { + JDBCSessionDataStoreFactory factory = new JDBCSessionDataStoreFactory() + { + @Override + public SessionDataStore getSessionDataStore(SessionManager manager) + { + JDBCSessionDataStore ds = new JDBCSessionDataStore() + { + @Override + public ObjectOutputStream newObjectOutputStream(OutputStream os) throws IOException + { + return JdbcTestHelper.newObjectOutputStream(os, compress); + } + + @Override + public ObjectInputStream newObjectInputStream(InputStream is) throws IOException + { + return JdbcTestHelper.newObjectInputStream(is, compress); + } + }; + ds.setDatabaseAdaptor(_adaptor); + ds.setSessionTableSchema(_schema); + ds.setGracePeriodSec(getGracePeriodSec()); + ds.setSavePeriodSec(getSavePeriodSec()); + return ds; + } + }; factory.setDatabaseAdaptor(da); JDBCSessionDataStore.SessionTableSchema sessionTableSchema = newSessionTableSchema(sessionTableName); factory.setSessionTableSchema(sessionTableSchema); @@ -224,7 +291,7 @@ public class JdbcTestHelper } @SuppressWarnings("unchecked") - public static boolean checkSessionPersisted(SessionData data, String sessionTableName) + public static boolean checkSessionPersisted(SessionData data, String sessionTableName, boolean compress) throws Exception { PreparedStatement statement = null; @@ -266,9 +333,10 @@ public class JdbcTestHelper if (blob.length() > 0) { try (InputStream is = blob.getBinaryStream(); - ClassLoadingObjectInputStream ois = new ClassLoadingObjectInputStream(is)) + ObjectInputStream ois = JdbcTestHelper.newObjectInputStream(is, compress)) { SessionData.deserializeAttributes(tmp, ois); + ois.close(); } } //same number of attributes @@ -292,7 +360,7 @@ public class JdbcTestHelper return true; } - public static void insertSession(SessionData data, String sessionTableName) throws Exception + public static void insertSession(SessionData data, String sessionTableName, boolean compress) throws Exception { try (Connection con = getConnection()) { @@ -317,14 +385,15 @@ public class JdbcTestHelper statement.setLong(11, data.getMaxInactiveMs()); try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(baos);) + ObjectOutputStream oos = newObjectOutputStream(baos, compress);) { SessionData.serializeAttributes(data, oos); + oos.close(); byte[] bytes = baos.toByteArray(); try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);) { - statement.setBinaryStream(12, bais, bytes.length); + statement.setBinaryStream(12, bais); } } statement.execute(); diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/ClusteredInvalidationSessionTest.java b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/ClusteredInvalidationSessionTest.java index d1350738d58..4a6e2843a96 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/ClusteredInvalidationSessionTest.java +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/ClusteredInvalidationSessionTest.java @@ -44,6 +44,6 @@ public class ClusteredInvalidationSessionTest extends AbstractClusteredInvalidat @Override public SessionDataStoreFactory createSessionDataStoreFactory() { - return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName); + return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName, false); } } diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/ClusteredOrphanedSessionTest.java b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/ClusteredOrphanedSessionTest.java index 264007cecdf..3500188c4eb 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/ClusteredOrphanedSessionTest.java +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/ClusteredOrphanedSessionTest.java @@ -38,7 +38,7 @@ public class ClusteredOrphanedSessionTest extends AbstractClusteredOrphanedSessi @Override public SessionDataStoreFactory createSessionDataStoreFactory() { - return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName); + return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName, false); } @AfterEach diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/ClusteredSessionMigrationTest.java b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/ClusteredSessionMigrationTest.java index 475229c0571..9ac84b16a87 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/ClusteredSessionMigrationTest.java +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/ClusteredSessionMigrationTest.java @@ -64,7 +64,7 @@ public class ClusteredSessionMigrationTest extends AbstractSessionTestBase @Override public SessionDataStoreFactory createSessionDataStoreFactory() { - return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName); + return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName, false); } @AfterEach diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/ClusteredSessionScavengingTest.java b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/ClusteredSessionScavengingTest.java index 13bf253b148..0516c6ca132 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/ClusteredSessionScavengingTest.java +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/ClusteredSessionScavengingTest.java @@ -37,7 +37,7 @@ public class ClusteredSessionScavengingTest extends AbstractClusteredSessionScav @Override public SessionDataStoreFactory createSessionDataStoreFactory() { - return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName); + return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName, false); } @AfterEach diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/JDBCSessionDataStoreCompressTest.java b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/JDBCSessionDataStoreCompressTest.java new file mode 100644 index 00000000000..9c0bb95aa7d --- /dev/null +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/JDBCSessionDataStoreCompressTest.java @@ -0,0 +1,125 @@ +// +// ======================================================================== +// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +package org.eclipse.jetty.ee10.session.jdbc; + +import org.eclipse.jetty.session.AbstractSessionDataStoreTest; +import org.eclipse.jetty.session.JdbcTestHelper; +import org.eclipse.jetty.session.SessionData; +import org.eclipse.jetty.session.SessionDataStore; +import org.eclipse.jetty.session.SessionDataStoreFactory; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.testcontainers.junit.jupiter.Testcontainers; + +@Testcontainers(disabledWithoutDocker = true) +public class JDBCSessionDataStoreCompressTest extends AbstractSessionDataStoreTest +{ + public static final boolean COMPRESS = true; + + class NonSerializable + { + int x = 10; + } + + public JDBCSessionDataStoreCompressTest() throws Exception + { + super(); + } + + private String sessionTableName; + + @BeforeEach + public void setupSessionTableName() throws Exception + { + this.sessionTableName = getClass().getSimpleName() + "_" + System.nanoTime(); + JdbcTestHelper.prepareTables(sessionTableName); + } + + @AfterEach + public void tearDown() throws Exception + { + JdbcTestHelper.shutdown(sessionTableName); + } + + @Override + public SessionDataStoreFactory createSessionDataStoreFactory() + { + return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName, COMPRESS); + } + + @Override + public void persistSession(SessionData data) + throws Exception + { + JdbcTestHelper.insertSession(data, sessionTableName, COMPRESS); + } + + @Override + public void persistUnreadableSession(SessionData data) throws Exception + { + JdbcTestHelper.insertUnreadableSession(data.getId(), data.getContextPath(), data.getVhost(), data.getLastNode(), + data.getCreated(), data.getAccessed(), data.getLastAccessed(), + data.getMaxInactiveMs(), data.getExpiry(), data.getCookieSet(), + data.getLastSaved(), sessionTableName); + } + + @Test + public void testCleanOrphans() throws Exception + { + super.testCleanOrphans(); + } + + @Override + public boolean checkSessionExists(SessionData data) throws Exception + { + return JdbcTestHelper.existsInSessionTable(data.getId(), false, sessionTableName); + } + + @Override + public boolean checkSessionPersisted(SessionData data) throws Exception + { + ClassLoader old = Thread.currentThread().getContextClassLoader(); + Thread.currentThread().setContextClassLoader(_contextClassLoader); + try + { + return JdbcTestHelper.checkSessionPersisted(data, sessionTableName, COMPRESS); + } + finally + { + Thread.currentThread().setContextClassLoader(old); + } + } + + @Test + public void testUnserializableSession() throws Exception + { + setUp(); + _server.start(); + + SessionDataStore store = _sessionManager.getSessionCache().getSessionDataStore(); + + //persist a session that has an unserializable attribute + long now = System.currentTimeMillis(); + SessionData data = store.newSessionData("xxx999", 100, now, now - 1, -1); //never expires + data.setLastNode(_sessionIdManager.getWorkerName()); + data.setAttribute("bad", new NonSerializable()); + + store.store("xxx999", data); + + data = store.load("xxx999"); + Assertions.assertNull(data.getAttribute("bad")); + } +} diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/JDBCSessionDataStoreTest.java b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/JDBCSessionDataStoreTest.java index 4d585c8f7e3..6a98e565212 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/JDBCSessionDataStoreTest.java +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/JDBCSessionDataStoreTest.java @@ -13,21 +13,36 @@ package org.eclipse.jetty.ee10.session.jdbc; +import java.io.NotSerializableException; + import org.eclipse.jetty.session.AbstractSessionDataStoreTest; import org.eclipse.jetty.session.JdbcTestHelper; import org.eclipse.jetty.session.SessionData; +import org.eclipse.jetty.session.SessionDataStore; import org.eclipse.jetty.session.SessionDataStoreFactory; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.testcontainers.junit.jupiter.Testcontainers; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThrows; + /** * JDBCSessionDataStoreTest */ @Testcontainers(disabledWithoutDocker = true) public class JDBCSessionDataStoreTest extends AbstractSessionDataStoreTest { + + class NonSerializable + { + int x = 10; + } + public JDBCSessionDataStoreTest() throws Exception { super(); @@ -51,14 +66,14 @@ public class JDBCSessionDataStoreTest extends AbstractSessionDataStoreTest @Override public SessionDataStoreFactory createSessionDataStoreFactory() { - return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName); + return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName, false); } @Override public void persistSession(SessionData data) throws Exception { - JdbcTestHelper.insertSession(data, sessionTableName); + JdbcTestHelper.insertSession(data, sessionTableName, false); } @Override @@ -89,11 +104,28 @@ public class JDBCSessionDataStoreTest extends AbstractSessionDataStoreTest Thread.currentThread().setContextClassLoader(_contextClassLoader); try { - return JdbcTestHelper.checkSessionPersisted(data, sessionTableName); + return JdbcTestHelper.checkSessionPersisted(data, sessionTableName, false); } finally { Thread.currentThread().setContextClassLoader(old); } } + + @Test + public void testUnserializableSession() throws Exception + { + setUp(); + _server.start(); + + SessionDataStore store = _sessionManager.getSessionCache().getSessionDataStore(); + + //persist a session that has an unserializable attribute + long now = System.currentTimeMillis(); + final SessionData data = store.newSessionData("xxx999", 100, now, now - 1, -1); //never expires + data.setLastNode(_sessionIdManager.getWorkerName()); + data.setAttribute("bad", new NonSerializable()); + + assertThrows(NotSerializableException.class, () -> store.store("xxx999", data)); + } } diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/ReloadedSessionMissingClassTest.java b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/ReloadedSessionMissingClassTest.java index dcb19d42611..ecea65faa44 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/ReloadedSessionMissingClassTest.java +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/ReloadedSessionMissingClassTest.java @@ -99,7 +99,7 @@ public class ReloadedSessionMissingClassTest DefaultSessionCacheFactory cacheFactory = new DefaultSessionCacheFactory(); cacheFactory.setEvictionPolicy(SessionCache.NEVER_EVICT); - SessionDataStoreFactory storeFactory = JdbcTestHelper.newSessionDataStoreFactory(sessionTableName); + SessionDataStoreFactory storeFactory = JdbcTestHelper.newSessionDataStoreFactory(sessionTableName, false); ((AbstractSessionDataStoreFactory)storeFactory).setGracePeriodSec(SessionTestSupport.DEFAULT_SCAVENGE_SEC); SessionTestSupport server1 = new SessionTestSupport(0, SessionTestSupport.DEFAULT_MAX_INACTIVE, SessionTestSupport.DEFAULT_SCAVENGE_SEC, cacheFactory, storeFactory); diff --git a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/WebAppObjectInSessionTest.java b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/WebAppObjectInSessionTest.java index fa6c42f871c..694e5838769 100644 --- a/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/WebAppObjectInSessionTest.java +++ b/jetty-ee10/jetty-ee10-tests/jetty-ee10-test-sessions/jetty-ee10-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee10/session/jdbc/WebAppObjectInSessionTest.java @@ -41,7 +41,7 @@ public class WebAppObjectInSessionTest extends AbstractWebAppObjectInSessionTest @Override public SessionDataStoreFactory createSessionDataStoreFactory() { - return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName); + return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName, false); } @Test diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/ClusteredInvalidationSessionTest.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/ClusteredInvalidationSessionTest.java index 2f8d949f8be..5719f039576 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/ClusteredInvalidationSessionTest.java +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/ClusteredInvalidationSessionTest.java @@ -44,6 +44,6 @@ public class ClusteredInvalidationSessionTest extends AbstractClusteredInvalidat @Override public SessionDataStoreFactory createSessionDataStoreFactory() { - return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName); + return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName, false); } } diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/ClusteredOrphanedSessionTest.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/ClusteredOrphanedSessionTest.java index 371b7d2dd7d..03a9c99147c 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/ClusteredOrphanedSessionTest.java +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/ClusteredOrphanedSessionTest.java @@ -38,7 +38,7 @@ public class ClusteredOrphanedSessionTest extends AbstractClusteredOrphanedSessi @Override public SessionDataStoreFactory createSessionDataStoreFactory() { - return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName); + return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName, false); } @AfterEach diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/ClusteredSessionMigrationTest.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/ClusteredSessionMigrationTest.java index 00e4289d7dc..7c23e9fb9bb 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/ClusteredSessionMigrationTest.java +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/ClusteredSessionMigrationTest.java @@ -64,7 +64,7 @@ public class ClusteredSessionMigrationTest extends AbstractSessionTestBase @Override public SessionDataStoreFactory createSessionDataStoreFactory() { - return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName); + return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName, false); } @AfterEach diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/ClusteredSessionScavengingTest.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/ClusteredSessionScavengingTest.java index 7ae4fafa6f5..5ae39b6db89 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/ClusteredSessionScavengingTest.java +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/ClusteredSessionScavengingTest.java @@ -37,7 +37,7 @@ public class ClusteredSessionScavengingTest extends AbstractClusteredSessionScav @Override public SessionDataStoreFactory createSessionDataStoreFactory() { - return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName); + return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName, false); } @AfterEach diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/JDBCSessionDataStoreTest.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/JDBCSessionDataStoreTest.java index 1e04699ccec..384f8655375 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/JDBCSessionDataStoreTest.java +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/JDBCSessionDataStoreTest.java @@ -51,14 +51,14 @@ public class JDBCSessionDataStoreTest extends AbstractSessionDataStoreTest @Override public SessionDataStoreFactory createSessionDataStoreFactory() { - return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName); + return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName, false); } @Override public void persistSession(SessionData data) throws Exception { - JdbcTestHelper.insertSession(data, sessionTableName); + JdbcTestHelper.insertSession(data, sessionTableName, false); } @Override @@ -89,7 +89,7 @@ public class JDBCSessionDataStoreTest extends AbstractSessionDataStoreTest Thread.currentThread().setContextClassLoader(_contextClassLoader); try { - return JdbcTestHelper.checkSessionPersisted(data, sessionTableName); + return JdbcTestHelper.checkSessionPersisted(data, sessionTableName, false); } finally { diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/ReloadedSessionMissingClassTest.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/ReloadedSessionMissingClassTest.java index 8f46e856cda..0e7c2f9698c 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/ReloadedSessionMissingClassTest.java +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/ReloadedSessionMissingClassTest.java @@ -97,7 +97,7 @@ public class ReloadedSessionMissingClassTest DefaultSessionCacheFactory cacheFactory = new DefaultSessionCacheFactory(); cacheFactory.setEvictionPolicy(SessionCache.NEVER_EVICT); - SessionDataStoreFactory storeFactory = JdbcTestHelper.newSessionDataStoreFactory(sessionTableName); + SessionDataStoreFactory storeFactory = JdbcTestHelper.newSessionDataStoreFactory(sessionTableName, false); ((AbstractSessionDataStoreFactory)storeFactory).setGracePeriodSec(SessionTestSupport.DEFAULT_SCAVENGE_SEC); SessionTestSupport server1 = new SessionTestSupport(0, SessionTestSupport.DEFAULT_MAX_INACTIVE, SessionTestSupport.DEFAULT_SCAVENGE_SEC, cacheFactory, storeFactory); diff --git a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/WebAppObjectInSessionTest.java b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/WebAppObjectInSessionTest.java index 3cbcd6f0663..52fb3137209 100644 --- a/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/WebAppObjectInSessionTest.java +++ b/jetty-ee9/jetty-ee9-tests/jetty-ee9-test-sessions/jetty-ee9-test-sessions-jdbc/src/test/java/org/eclipse/jetty/ee9/session/jdbc/WebAppObjectInSessionTest.java @@ -40,7 +40,7 @@ public class WebAppObjectInSessionTest extends AbstractWebAppObjectInSessionTest @Override public SessionDataStoreFactory createSessionDataStoreFactory() { - return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName); + return JdbcTestHelper.newSessionDataStoreFactory(sessionTableName, false); } @Test diff --git a/jetty-integrations/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/NoSqlSessionDataStore.java b/jetty-integrations/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/NoSqlSessionDataStore.java index bd5efc24e60..211812c75ba 100644 --- a/jetty-integrations/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/NoSqlSessionDataStore.java +++ b/jetty-integrations/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/NoSqlSessionDataStore.java @@ -16,13 +16,13 @@ package org.eclipse.jetty.nosql; import java.util.HashSet; import java.util.Set; -import org.eclipse.jetty.session.AbstractSessionDataStore; +import org.eclipse.jetty.session.ObjectStreamSessionDataStore; import org.eclipse.jetty.session.SessionData; /** * NoSqlSessionDataStore */ -public abstract class NoSqlSessionDataStore extends AbstractSessionDataStore +public abstract class NoSqlSessionDataStore extends ObjectStreamSessionDataStore { public class NoSqlSessionData extends SessionData diff --git a/jetty-integrations/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionDataStore.java b/jetty-integrations/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionDataStore.java index 01a77236159..3395f9bb1f7 100644 --- a/jetty-integrations/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionDataStore.java +++ b/jetty-integrations/jetty-nosql/src/main/java/org/eclipse/jetty/nosql/mongodb/MongoSessionDataStore.java @@ -15,6 +15,7 @@ package org.eclipse.jetty.nosql.mongodb; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.HashMap; import java.util.HashSet; @@ -34,7 +35,6 @@ import org.eclipse.jetty.nosql.NoSqlSessionDataStore; import org.eclipse.jetty.session.SessionContext; import org.eclipse.jetty.session.SessionData; import org.eclipse.jetty.session.UnreadableSessionDataException; -import org.eclipse.jetty.util.ClassLoadingObjectInputStream; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.annotation.ManagedAttribute; import org.eclipse.jetty.util.annotation.ManagedObject; @@ -239,10 +239,9 @@ public class MongoSessionDataStore extends NoSqlSessionDataStore else { //attributes have special serialized format - try (ByteArrayInputStream bais = new ByteArrayInputStream(attributes); - ClassLoadingObjectInputStream ois = new ClassLoadingObjectInputStream(bais);) + try (ByteArrayInputStream bais = new ByteArrayInputStream(attributes);) { - SessionData.deserializeAttributes(data, ois); + deserializeAttributes(data, bais); } } } @@ -514,10 +513,9 @@ public class MongoSessionDataStore extends NoSqlSessionDataStore sets.put(__ACCESSED, data.getAccessed()); sets.put(__LAST_ACCESSED, data.getLastAccessed()); - try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(baos);) + try (ByteArrayOutputStream baos = new ByteArrayOutputStream();) { - SessionData.serializeAttributes(data, oos); + serializeAttributes(data, baos); sets.put(getContextSubfield(__ATTRIBUTES), baos.toByteArray()); }