Issue Details (XML | Word | Printable)

Key: LDAP-14
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Ulrik Sandberg
Reporter: Jasper Blues
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Spring LDAP

Exceptions not Serializable

Created: 07/Nov/06 05:49 PM   Updated: 25/Mar/07 03:10 PM   Resolved: 25/Mar/07 03:10 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.2-RC1

Time Tracking:
Not Specified


 Description  « Hide

Hello

We have a remote service utilizing Spring-Ldap. We'd like to be able to return exceptions to the service caller, however they're not Serializable

Perhaps it is the wrapped NamingException that is not Serializable. My preference is for the exceptions to be serializable (perhaps there are other points of view), therefore I'd suggest to wrap the stack trace and message from NamingException and discard the non-Serializable part.

Regards,
Jasper



Ulrik Sandberg added a comment - 12/Jan/07 10:40 AM

We have now converted from DataAccessException to an unchecked mirror of NamingException (in SVN trunk). I guess the problem remains, since we still wrap the checked NamingExceptions.


Jasper Blues added a comment - 14/Jan/07 05:47 PM

From one user's point of view I still prefer Serializable Exceptions. Perhaps when checked exceptions are caught and re-thrown as a mirrored-unchecked a test for instanceof Serializable could be performed? . . . And when not serializable discard the exception for the message and stack-trace?


Ulrik Sandberg added a comment - 16/Feb/07 08:44 AM

All exceptions should be able to serialize themselves, since Throwable implements Serializable. In order to pinpoint which Exception is causing this, we would need a stack trace from your remoting stuff.


Ulrik Sandberg added a comment - 16/Feb/07 09:45 AM

Now I can see the problem. There are no restrictions on setResolvedObj of NamingException. This means resolvedObj can be non-serializable, and in that case the serialization fails. It seems to be a known problem. One proposed workaround is to have a custom writeObject method that writes a null resolvedObj if it can be determined that it is not serializable. It's not foolproof, since even if resolvedObj implements Serializable, some object in the object graph below it might not.


Ulrik Sandberg added a comment - 23/Feb/07 07:21 AM

I have checked in a possible solution where I implemented a custom writeObject that temporarily nulls out the resolvedObj before serialization. See the unit test for it in org.springframework.ldap.NamingExceptionTest. Please confirm that it solves your problem.


Ulrik Sandberg added a comment - 25/Mar/07 03:03 PM

Verified by Jasper.