Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Serializing Boolean?  RSS feed

 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I encountered a strange problem recently. I was serializing a Vector of HashMaps. Each HashMap contained String[], int[], Object[] and one Boolean Object. Now, I was always getting EOFException. Could not figure out what was causing it, and then by trial-error found out that it was Boolean Object. The moment I represented Boolean as primitive and put it into boolean[] and into the HashMap everything worked fine. Last time I checked Boolean implemented Seializable, so what's the problem? Any ideas?

thanks,
Alex
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Show us some code.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that I've deleted other copies of this thread, twice now. Please don't cross-post. Instead, let's work on this question here in this thread. So show us some code -- what are you doing exactly?
 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for double post.
Here is the code:

And here is function for saveSessionInBinaryBoolean()

[ June 15, 2005: Message edited by: Alex Kravets ]
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Technically, I don't believe the servlet is guaranteed to be able to read all the data until you call close() on the OutputStream in the client. You're closing it, but not until after trying to read the input. Move the out.close() to up before where you open the ObjectInputStream, and see if that doesn't straighten things out.
 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
tried it. Same thing.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!