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*
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.
You’re welcome!
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!!!
You’re most welcome. I’m glad I could be of help!