Community
Participate
Working Groups
Build Identifier: 7.5.1.v20110908 The MongoSessionManager throws an error when it tries to deserialize a POJO. It looks to be an issue with the way the object is serialized to a byte array on storage into Mongo. Attaching a patch to fix the issue. 2011-09-14 11:26:28.698:WARN:oejnm.MongoSessionManager: java.io.StreamCorruptedException: invalid stream header: 79737200 at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:782) at java.io.ObjectInputStream.<init>(ObjectInputStream.java:279) at org.eclipse.jetty.nosql.mongodb.MongoSessionManager.decodeValue(MongoSessionManager.java:447) at org.eclipse.jetty.nosql.mongodb.MongoSessionManager.loadSession(MongoSessionManager.java:318) at org.eclipse.jetty.nosql.NoSqlSessionManager.getSession(NoSqlSessionManager.java:68) at org.eclipse.jetty.server.session.AbstractSessionManager.getHttpSession(AbstractSessionManager.java:254) at org.eclipse.jetty.server.session.SessionHandler.checkRequestedSessionId(SessionHandler.java:269) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:152) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:874) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110) at org.eclipse.jetty.server.Server.handle(Server.java:349) at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:441) at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:904) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:565) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:217) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:46) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:545) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:43) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533) at java.lang.Thread.run(Thread.java:680) Reproducible: Always Steps to Reproduce: 1. Put the attached TestServlet.java into a project and deploy it to a container using Mongo backed sessions. Default options are fine. 2. Hit the servlet a few times and note the count going up in the logs. 3. Restart your server to clear the in memory sessions. 4. Hit the servlet from the same browser as before. You should get an error when CountHolder is deserialized and the count will start over since the relevant session data could not be retrieved
Created attachment 203360 [details] Patch to Fix the issue This patch removes the call to reset the byte stream that underlies the object output stream. It seems that this call was wiping out the header information for the serialization.
Created attachment 203361 [details] Servlet that illustrates the error condition
John, removed the line you found and will have that committed shortly, I'll leave this issue open though and assign to me so I can build out a proper test case for this case
closing since mongo tests require a server we should work out another way to test it