This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Awkward Memory Issues Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Awkward Memory Issues" Watch "Awkward Memory Issues" New topic
Author

Awkward Memory Issues

Sid Singh
Greenhorn

Joined: Jun 14, 2010
Posts: 20

Hi Folks,

I came across a strange problem while unit testing of my application accross various environments like first local server then pre-production server and so on.
I was getting below exception
java.io.IOException: Underlying input stream returned zero bytes

Tried lot many things but all failed. Then i realised that the data size that i was testing with was a bit large so i reduced the size and with the same code things went well.
On different server even with the large data set my code was running properly.
I wonder such exception in no way depicts about the actual problem.

Can someone throw some light on this?
Thanks
Siddharth


OCPJP 6, SCWCD In Progress
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19654
    
  18

Can you show us the code that's throwing that exception, plus the stack trace?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Sid Singh
Greenhorn

Joined: Jun 14, 2010
Posts: 20

Rob Spoor wrote:Can you show us the code that's throwing that exception, plus the stack trace?


Hi Rob,
Thanks for replying



The lines marked bold always throw the IOException and then it gets propogated from there.
The Trace which i got was

java.io.IOException: Underlying input stream returned zero bytes
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:268)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at java.io.BufferedReader.fill(BufferedReader.java:136)
at java.io.BufferedReader.readLine(BufferedReader.java:299)
at java.io.BufferedReader.readLine(BufferedReader.java:362)
at com.database.DatabaseServices.getPacketData(DatabaseServices.java:134)

Thanks
Siddharth Singh

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19654
    
  18

You're trying to read text data from a BLOB. Perhaps that BLOB is not a properly encoded string, or it's not encoded with the default encoding. In the latter case you can specify the actual encoding in the InputStreamReader constructor. In the former case you can't convert the BLOB into a String at all.

Perhaps it's a better idea to start using a CLOB instead of a BLOB. BLOB is Binary Large OBject, meant for binary data. CLOB is Character Large OBject, meant for text. JDBC uses Reader and Writer for CLOB.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Awkward Memory Issues
 
Similar Threads
JSP buffer size issue
cache could speed-up IE rendering?
JTable with inseting and autonumbering problem
java.lang.OutOfEMemoryError
ObjectInputStream creating OutOfMemoryError