Results 1 to 1 of 1
- 07-22-2009, 10:10 PM #1
Trouble resolving a StreamCorruptedException
Hey guys. ;)
I'm having trouble resolving a java.io.StreamCorruptedException exception. I'm working on a system that supports file management over a network connection. So, I've built my own file service and other things. The strange thing is, it works most of the time. I'm testing it for "large" files, say 5MB each, not really large. But anyway, when I transmit about 15 MB or more it pops this exception. But for 11 files each about 800 KB, there's no problem. Also, if I transmit 10 MB, reset the server's services and then transmit the other 5 MB there's no problem. Bazaar. The server I wrote gave me this log printout:
So it looks like the downstream class is causing the trouble. Don't know why, because it works perfectly except for this.Java Code:database service started server control service started file service started Server started, IP Address 192.168.1.101 Node connected: 192.168.1.101 Exception caught: [COLOR="RoyalBlue"]java.io.StreamCorruptedException[/COLOR]: invalid type code: 00 Stack Trace: 1 Method: readObject0 Class: java.io.ObjectInputStream Line: 1356 2 Method: readObject Class: java.io.ObjectInputStream Line: 351 3 Method: run Class: jnet.core.[COLOR="RoyalBlue"]JNetDownStream[/COLOR] Line: 57 4 Method: run Class: java.lang.Thread Line: 619 Node disconnected: 192.168.1.101 Exception caught: java.lang.Exception: JNet file transfer timed out Stack Trace: 1 Method: run Class: jnet.file.JNetFileReciever Line: 77 2 Method: run Class: java.lang.Thread Line: 619
jnet.core.JNetDownStream.java
Please note that I have a lot of related classes. 25 in the network component alone. I think this problem could be a Java bug. I've got the latest JRE (6) installed.Java Code:package jnet.core; import java.util.*; import java.net.*; import java.io.*; public class JNetDownStream implements Runnable { protected boolean running = true; protected boolean reading = false; protected Vector<JObjectListener> objectListeners; protected Thread thread; protected InputStream inputStream; protected BufferedInputStream buffer; protected ObjectInputStream objectInputStream; protected JDisconnectable disconnectable; public JNetDownStream(InputStream inputStream, JDisconnectable disconnectable) { try { this.disconnectable = disconnectable; this.inputStream = inputStream; buffer = new BufferedInputStream(this.inputStream); objectInputStream = new ObjectInputStream(buffer); objectListeners = new Vector<JObjectListener>(); thread = new Thread(this); thread.start(); } catch (Exception e) { JNetException.notifyExceptionThrown(e); abort(); } } protected void abort() { disconnectable.abort(); stop(); } protected void notifyObjectListeners(Object object) { for (JObjectListener objectListener : objectListeners) objectListener.objectRead(object); } public void addObjectListener(JObjectListener objectListener) { objectListeners.add(objectListener); } public void removeObjectListener(JObjectListener objectListener) { objectListeners.remove(objectListener); } public void run() { while (running) { try { Thread.sleep(20); reading = true; Object next = objectInputStream.readObject(); reading = false; notifyObjectListeners(next); } catch (EOFException f) { // ignore } catch (SocketTimeoutException t) { // ignore } catch (Exception e) { reading = false; JNetException.notifyExceptionThrown(e); abort(); } finally { reading = false; } } } public void stop() { running = false; try { while (reading) { Thread.sleep(100); } } catch (Exception e) { // ignore } } }
I've spent a lot of time on Google on this. Maybe someone can help.
Thank you. ;)
TimLast edited by tim; 07-22-2009 at 10:31 PM.
Eyes dwelling into the past are blind to what lies in the future. Step carefully.
Similar Threads
-
I got a problem with StreamCorruptedException, any ideas?
By Goodwine in forum New To JavaReplies: 8Last Post: 11-05-2010, 10:26 PM -
StreamCorruptedException
By cristo_haris in forum Advanced JavaReplies: 11Last Post: 04-20-2009, 03:44 PM -
StreamCorruptedException and Casting troubles
By Wassa in forum NetworkingReplies: 2Last Post: 02-18-2009, 03:07 PM -
java.io.StreamCorruptedException
By elizabeth in forum Advanced JavaReplies: 1Last Post: 08-06-2007, 06:45 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks