Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Socket / writeObject / NotSerializableException question

Reply
Thread Tools

Socket / writeObject / NotSerializableException question

 
 
JMC
Guest
Posts: n/a
 
      04-07-2004
Suppose a stream socket connection exists between P[roducer] and
C[onsumer], where P has an ObjectOutputStream on the socket and C has
an ObjectInputStream.

Then if P makes a sequence of OOS.writeXxxx calls, and these are not
matched exactly in sequence by OIS.readXxxx calls by C, then C will of
course get out of step and throw an exception, for example
OptionalDataException.

However, if P only makes OOS.writeObject calls, and C only makes
OIS.readObject calls, then they will stay in step as long as
OOS.writeObject does not throw a NotSerializableException.

But what if one of P's calls to OOS.writeObject does throw a
NotSerializableException, e.g. because some sub-sub-object deep in the
argument's graph is not serialisable? Then C's corresponding
OIS.readObject will get some sort of "malformed" object (or perhaps
null).

But then say P's next call to OOS.writeObject does not raise the
exception. Is it guaranteed that C will stay in step, and successfully
read the object? Or is it the case that sometimes P and C will need to
reset their connection to get back in step when P gets a
NotSerializableException?
 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      04-07-2004
On 7 Apr 2004 05:01:35 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) (JMC) wrote or
quoted :

>But then say P's next call to OOS.writeObject does not raise the
>exception. Is it guaranteed that C will stay in step, and successfully
>read the object? Or is it the case that sometimes P and C will need to
>reset their connection to get back in step when P gets a
>NotSerializableException?


When you write an object, it is a blob consisting of the object and
its dependents. If something goes wrong with the read, the stream
will be sitting at the end of the blob ready to try the next object.

I would think that if one of the subobjects was faulty, you would have
a half read tree of objects in RAM, but without a master object to
point to them, they would soon be garbage collected.

It should not be hard to try an experiment to ensure it can stay in
sync. Just leave out one of the classes from the receiver.

http://mindprod.com/jgloss/fileio.html for sample code.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help java.io.NotSerializableException Netlopa Java 2 06-04-2009 12:49 AM
drag and drop NotSerializableException on unique node 6e Java 3 11-10-2005 09:57 PM
debug RMI NotSerializableException Shin Java 7 08-03-2005 06:28 PM
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: Shannon Java 3 01-09-2004 05:18 AM
NotSerializableException owing to Container.add JCM Java 1 08-11-2003 03:46 PM



Advertisments