Issue Details (XML | Word | Printable)

Key: CHAIN-12
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Jeff Ramsdale
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons Chain

[chain] ContextBase throws NotSerializable exception for PropertyDescriptor

Created: 12/Apr/05 08:17 AM   Updated: 06/Jun/06 11:43 PM
Return to search
Component/s: None
Affects Version/s: 1.0
Fix Version/s: None

Time Tracking:
Not Specified

Environment:
Operating System: other
Platform: Other

Bugzilla Id: 34409


 Description  « Hide
It seems ContextBase is intended to be serializable (
http://jakarta.apache.org/commons/chain/apidocs/serialized-form.html &
http://marc.10east.com/?l=jakarta-commons-user&m=111323289317819&w=2 ), but an
attempt to serialize a simple subclass throws the following:

java.io.NotSerializableException: java.beans.PropertyDescriptor
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
at java.util.HashMap.writeObject(HashMap.java:978)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:809)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1296)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1332)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1304)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1332)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1304)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:278)
at
net.sourceforge.cruisecontrol.ProjectTest.testDeserialization(ProjectTest.java:371)

<snip />



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Craig McClanahan added a comment - 17/Apr/05 04:57 AM
Fixed in nightly build 20050417, and added a unit test to prove that ContextBase
can be serialized and deserialized successfully.

However, there is an issue with the WebContext implementations – they subclass
ContextBase and inherit the "implements Serializable" contract, but they cannot
in fact be serialized because they wrap container objects (request, response,
context) that are not serializable. Therefore, I'm leaving this bug report open
as we explore potential solutions to that issue.


Henri Yandell made changes - 16/May/06 09:53 AM
Field Original Value New Value
issue.field.bugzillaimportkey 34409 12342177
Henri Yandell made changes - 16/May/06 11:10 AM
Affects Version/s 1.0 Final [ 12311651 ]
Key COM-2025 CHAIN-12
Component/s Chain [ 12311103 ]
Assignee Craig McClanahan [ craig.mcclanahan@sun.com ]
Project Commons [ 12310458 ] Commons Chain [ 12310462 ]
Henri Yandell made changes - 16/May/06 12:14 PM
Affects Version/s 1.0 Final [ 12311700 ]
Joe Germuska added a comment - 24/May/06 09:17 PM
Why not just mark those container objects as transient?

Niall Pemberton added a comment - 25/May/06 09:49 AM
Marking them as transient would get rid of the serialization exception, but unless theres some smart way of getting hold of the wrapped container objects (request, context etc.) when a WebContext implementation is de-serialized then it just moves the problem along.

Joe Germuska added a comment - 25/May/06 08:15 PM
I agree that it just moves the problem along, but it seems to me that moving it along is the appropriate response. You can't remove "Serializable" (especially not as long as ContextBase extends HashMap) so you need to leave the responsibility for the wrinkles to users of the library.

What else could be done?


Rahul Akolkar added a comment - 25/May/06 10:12 PM
Reminds me of this thread:

http://marc.theaimsgroup.com/?t=113339368800002&r=1&w=2

I do agree with Niall that moving the problem along is probably not the right solution (i.e. a NotSerializableException might still be better than, say, an NPE after subsequent deserialization – from the "if its fatal, die quickly" camp). Perhaps note as a known issue for 1.1?


Repository Revision Date User Message
ASF #412150 Tue Jun 06 15:31:50 UTC 2006 niallp Further fix for CHAIN-12 - Using JDK 1.4.2_10 ContextBase can be serialized, but JDK 1.4.2_11 (and 1.3.1_04) fail trying to serialize - thanks to Dennis Lundberg for spotting this.
Files Changed
MODIFY /jakarta/commons/proper/chain/trunk/src/java/org/apache/commons/chain/impl/ContextBase.java
MODIFY /jakarta/commons/proper/chain/trunk/xdocs/changes.xml

Niall Pemberton added a comment - 06/Jun/06 11:43 PM
Dennis Lundberg found that TestContextTestCase failed the serialization test with JDK 1.4.2_11 when checking out Chain 1.1 release candidate 1. This test passed with JDK 1.4.2_10 but fails with the later JDK and also JDK 1.3.1_04.

Changing the static "placeholder" object for properties to be Seralizable appears to have fixed this:

http://svn.apache.org/viewvc?view=rev&revision=412150