Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 370368

Summary: Serialization of a Map with non-string value in the MongoSessionHandler is causing a stackoverflow due to infinite loop
Product: [RT] Jetty Reporter: David Seymore <david.seymore>
Component: otherAssignee: Jesse McConnell <jesse.mcconnell>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jesse.mcconnell
Version: unspecified   
Target Milestone: 7.5.x   
Hardware: PC   
OS: Linux   
Whiteboard:

Description David Seymore CLA 2012-02-01 14:34:10 EST
Build Identifier: 8.1.0.v20120127

Exception in thread "Thread-1" java.lang.StackOverflowError
        at java.util.regex.Pattern$Start.match(Pattern.java:3055)
        at java.util.regex.Matcher.search(Matcher.java:1105)
        at java.util.regex.Matcher.find(Matcher.java:535)
        at java.util.regex.Matcher.replaceAll(Matcher.java:809)
        at java.lang.String.replace(String.java:2207)
        at org.eclipse.jetty.nosql.mongodb.MongoSessionManager.encodeName(MongoSessionManager.java:398)
        at org.eclipse.jetty.nosql.mongodb.MongoSessionManager.encodeName(MongoSessionManager.java:424)


Reproducible: Always

Steps to Reproduce:
1. Enable the MongoDB session handler using the jetty-nosql module
2. Add a hashmap to the session with a value that is not a string (Long in my case)
3. send a kill signal to the jvm to flush to mongodb

The error appears to be on line 424

o.append(encodeName(entry.getKey().toString()),encodeName(out,bout,value));

It appears as though it should be passing the entry.getValue() rather than value (the map) to the recursive call to encodeName.
Comment 1 Jesse McConnell CLA 2012-02-01 14:45:06 EST
hm, I'll take a look

thanks for the report
Comment 2 Jesse McConnell CLA 2012-02-01 15:04:18 EST
its a bit of a pain to test since since I don't have a mongo service setup at the moment, but I can see where this would be a problem

have you tested your fix at all? or will you be willing to test a snapshot of this if I push it out?

thanks
Comment 3 David Seymore CLA 2012-02-01 15:08:10 EST
I have just tested the fix locally building off the tag. I do see the objects being pushed into mongodb now, and stack overflow is no longer being expressed in the logs.
Comment 4 Jesse McConnell CLA 2012-02-01 15:11:23 EST
ok, I pushed it into master

I am working on the merge to 8 anyway for some dependency work we did so it
should be on jetty 8 sometime today

thanks for the report and simple fix!

cheers