This has to do with not flushing the stream I believe. That or appending your input stream.

Try to stream.flush() and copy.flush() before you call readObject()

04-15-2009, 07:07 PM

OrangeDog

If you were able to flush an input stream you'll throw away all the data. Flushing is for output streams.

The answer is simply that the stream is corrupted. Whatever copyName refers to, it is not a valid ObjectInputStream. If it is the target of an ObjectOutputStream then something has happened to corrupt it before you read it - a file system error or a lost packet perhaps.

Also, as stream and copy represent the same stream, you don't need to call stream.close() after calling copy.close().

04-15-2009, 07:33 PM

neilcoffey

The mistake will probably be in the code that's writing the object at the other end.

04-15-2009, 07:47 PM

neilcoffey

By the way-- I forgot to say, don't forget to use a BufferedInputStream-- performance of object streams is terrible otherwise.

04-16-2009, 01:40 PM

cristo_haris

Hi,

Quote:

Originally Posted by xcallmejudasx

This has to do with not flushing the stream I believe. That or appending your input stream.

Try to stream.flush() and copy.flush() before you call readObject()

There is no flush() method for FileInputStream & ObjectInputStream :(

04-16-2009, 01:54 PM

cristo_haris

StreamCorruptedException : Eclipse Ganymede(Backup and Restore)

Hi,

Quote:

Originally Posted by OrangeDog

If you flush an input stream you'll throw away all the data. Flushing is for output streams.

The answer is simply that the stream is corrupted. Whatever copyName refers to, it is not a valid ObjectInputStream. If it is the target of an ObjectOutputStream then something has happened to corrupt it before you read it - a file system error or a lost packet perhaps.

Also, as stream and copy represent the same stream, you don't need to call stream.close() after calling copy.close().

Yes I agree that the stream is corrupted, but what can be the root cause for it and also a proper solution to fix it

Let me explain the scenario which end up this exception...

I have developed an RCP application (Using eclipse 3.3) which have backup and restore functionality. And this code was working fine.
But recently that application was migrated to eclipse 3.4.1 (Eclipse Ganymede) and then it is throwing this exception while restoring the backups created from Eclipse 3.3 version but working fine while restoring the backups generated from Eclipse Ganymede

04-16-2009, 02:01 PM

OrangeDog

I'm guessing that eclipse changed their classes between the versions, rendering the old backups incompatible. Serialized objects aren't guaranteed to still work if the class definitions change - you want JavaBeans for that. Possibly they didn't use or change serialVersionIDs properly. Doesn't look like there's much you can do - maybe try asking the eclipse developers?

04-16-2009, 02:17 PM

cristo_haris

Ok... let me try with the eclipse developers...

04-18-2009, 09:10 AM

cristo_haris

Quote:

Originally Posted by OrangeDog

I'm guessing that eclipse changed their classes between the versions, rendering the old backups incompatible. Serialized objects aren't guaranteed to still work if the class definitions change - you want JavaBeans for that. Possibly they didn't use or change serialVersionIDs properly. Doesn't look like there's much you can do - maybe try asking the eclipse developers?

This was the reply I got from eclipse developers

"You are using only java.io.....
Maybe you are using a different version of java as well?
Try to ask about this problem on the runtime newsgroup.
Closing as not eclipse"

What to do :confused:

04-18-2009, 04:21 PM

OrangeDog

What exactly is it that you are serializing?

04-20-2009, 03:44 PM

cristo_haris

Quote:

Originally Posted by OrangeDog

What exactly is it that you are serializing?

Hi,

My issue fixed !!!!!!

The file I was expecting was an obfustigated one, but due to some issues it was not obfustigated, found out the root cause and fixed it,

Thank God :)

And also thanks for all of you who have responded to this issue prombly...