I agree with you that there is nothing wrong with the design of the Employee
class.  The BeanSerializer simply does not have the feature of Java
serialization (courtesy of ObjectOutputSteam) that allows serialization of a
cyclic graph.  Whether this is a bug or a pragmatic limitation depends on
your point of view.  Either way, if you could contribute the code to add
this feature, I am sure there will be grateful Apache SOAP users.

Scott

----- Original Message -----
From: "Soumen Sarkar" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, July 13, 2001 6:34 PM
Subject: RE: Bugs in Soap 2.2 BeanSerializer?


> Hello there,
>
> The point I am trying to make is there is nothing wrong with the design of
> Employee class. Please read on...
>
> The problem is with the BeanSerializer class -- which is supposed to keep
> track
> of what object has been traversed in course of XML
> marshalling/unmarshalling.
>
> I will pose a simple question here : Why this Java class instance can
> successfully be
> exchanged over the wire using Java RMI protocol? Why there is no stack
> overflow?
>
> In my opinion the answer is Java RMI can successfully
serialize/deserialize
> a Java
> Object graph (containing cycles) which is not the case with
BeanSerializer.
> My original
> post was to verify just this fact.
>
> Now coming to your example, toString() is bound to cause stack overflow
> because you are
> not checking for cycles in your toString() implementation. I say this to
> drive home the point
> that there is nothing wrong with Employee class containing a field named
> 'subordinates'
> which is of type Employee[] (or Vector of Employee). I know that this kind
> of data strcture
> may lead to cyclic graph (and thus endless loop in naive implementation of
> toString()). But
> my whole point is a serialization algorithm (toString() is a serialization
> procedure) is
> supposed to flatten a cyclic graph to acyclic one while retaining graph
> semantics intact!
>
> Thanks for discussing this issue.
>
> Reagrds,
> Soumen.
>
> -----Original Message-----
> From: Aleksander Slominski [mailto:[EMAIL PROTECTED]]
> Sent: Friday, July 13, 2001 3:17 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Bugs in Soap 2.2 BeanSerializer?
>
>
> hi,
>
> java does not have containment (or by value) storage - all is by reference
> so if your references are cyclic BeanSerializer will fail...
>
> i have checked your code and it seems as if you never used it to print
> values you are sending or you would easily see that to reproduce it is
> enough just to call your toString(), for example:
>
>           Employee A = new Employee();
>           Employee M = new Employee();
>           A.setManager(M);
>           Vector subordinates = new Vector();
>           subordinates.addElement(A);
>           M.setSubordinates(subordinates);
>           System.out.println("manger M="+M);
>
> when i run it i get this:
>
> Exception in thread "main" java.lang.StackOverflowError
>         at java.lang.FloatingDecimal.<init>(Unknown Source)
>         at java.lang.Double.toString(Unknown Source)
>         at java.lang.String.valueOf(Unknown Source)
>         at java.lang.StringBuffer.append(Unknown Source)
>         at Employee.toString(Employee.java:90)
>         at java.lang.String.valueOf(Unknown Source)
>         at java.lang.StringBuffer.append(Unknown Source)
>         at Employee.toString(Employee.java:91)
>         at java.lang.String.valueOf(Unknown Source)
>         at java.lang.StringBuffer.append(Unknown Source)
>         at Employee.toString(Employee.java:97)
>         at java.lang.String.valueOf(Unknown Source)
>         at java.lang.StringBuffer.append(Unknown Source)
>         at Employee.toString(Employee.java:91)
>         at java.lang.String.valueOf(Unknown Source)
>         at java.lang.StringBuffer.append(Unknown Source)
>
> and so on for hundreds of lines...
>
> thanks,
>
> alek
>

Reply via email to