Mantis - Hessian
Viewing Issue Advanced Details
3268 minor always 01-15-09 13:39 02-24-09 18:44
emil  
 
normal  
closed 3.2.1  
fixed  
none    
none  
0003268: Circular references in Hessian Flex
(rep by bryan)

In the current implementation ( hessian-flex-3.2.0-src.jar ):

If an Object which is Serialized contains a circular reference to itself
i.e. Project -> Project, then HessianOutput will crash with a stack
overflow.

The reason for this, is it doesn't do anything to handle circular
references, I suspect a more complete handling would require a rewrite of
the handleObject and handleObject10 methods passing recursively a Map of
reference objects down the call stack to properly solve this the reference
way.

This code just fixes it one level deep, but it's better than nothing and
fixes the most common case.


[-- Attachment 0000002: HessianOutput.patch.txt --]
[-- Type: text/plain, Encoding: 7bit, Size: 0.8K --]

Index: flex/hessian/src/hessian/io/HessianOutput.as
===================================================================
--- flex/hessian/src/hessian/io/HessianOutput.as (revision 190)
+++ flex/hessian/src/hessian/io/HessianOutput.as (working copy)
@@ -376,7 +376,15 @@

             if (key != "hessianTypeName") {
               writeObject(key);
- writeObject(obj[key]);
+ //Very crude, yet it works, prevent crashing on recursive
+relationships by not sending them
+ if(obj[key] != obj){
+ writeObject(obj[key]);
+ }
+ else{
+ trace("should be writing a reference here but writing null is
+the " +
+ "next best thing when encountering a circular
+references");
+ writeNull();
+ }
             }

             break;

Notes
(0003837)
emil   
02-24-09 18:44   
Fixed in version 4.0