ObjectOutputStream & ObjectInputStream Woes

As I’ve now decided to go ahead and use Serialization in my application and differentiating the data by giving leading bits indicating what type of data is about to come in I am now using ObjectOutputStream and ObjectInputStream.  This application needs to be working by Wednesday so obviously I’m in a bit of rush to get this to work and today got completely stuck when the application decided to pause.  Of course it’s threaded so the whole thing didn’t just die, but when a window was supposed to pop up, nothing happened.  I traced through the code, shoved test cases here and there and still couldn’t figure it out.

The moment that ObjectOutputStream and ObjectInputStream were being created, it got stuck, for no reason.  Type Exception wasn’t caught, and nothing else was thrown.  I sat and waited thinking that something is just going slow but d’ya know what? Nothing happened.

Eventually I hopped on IRC (a great resource for situations like this) and found that ObjectOutputStream needs to be constructed first as it sends setup data.  So, if you’re using Serialization over Sockets and your application decides to stop processing when constructing these types, remember to instantiate ObjectOutputStream before ObjectInputStream.

*grumbles* ;)

About Kieran

A twenty-four year old software developer from Guernsey, Channel Islands.
This entry was posted in Pages. Bookmark the permalink.

4 Responses to ObjectOutputStream & ObjectInputStream Woes

  1. Nick says:

    Just wanted to say THANK YOU! Im writing a java networking app for a class I’m in and I was stuck on this problem for a good hour or two until i googled “objectinputstream stuck” in desperation. Thanks a bunch.

  2. Kieran says:

    You’re welcome!

  3. Byrne says:

    One year later and your post is still helping people :) this helped me solve a problem i would otherwise have no clue about. Thanks so much for sharing!!!

  4. Kieran says:

    You’re most welcome. I’m glad I could be of help!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>