Hello,
I have encountered a strange behavior of ObjectInputStream, while reading a large object (ArrayList).
If I forcefully interrupt the connection (disconnecting the cable or disabling the wireless network adapter),
the readObject() method simply blocks, and does not throw an exception.
however if the application on the sending side exits forcefully (via "X" button or by ending the process in "Task Manager"), an exception is thrown as it should be.
private void parseScene_obj() throws IOException {
try {
System.out.println("BEFORE");
scene = (ArrayList<CollidableObject>) objectInputStream.readObject();
System.out.println("AFTER");
System.out.println(" Parsed "+scene.size()+" CollidableObjects ");
//BoundingIntervalHierarchyTree bih=new BoundingIntervalHierarchyTree(scene);
} catch (ClassNotFoundException ex) {
Logger.getLogger(TCPclient.class.getName()).log(Level.SEVERE, null, ex);
}
finally{
System.out.println("IN FINALLY");
}
}
The code above shows the problem , only "BEFORE" is printed , then the program hangs.
any help would be appreciated.
*SOLVED:_
it seems that the exception takes a long time to be thrown,
*(I waited 10 minutes, and did not see any exception thrown)*
the simple solution was sending the objects one by one, instead of sending a WHOLE arrayList as a big object.
that way an exception was thrown after 2~3 seconds
Edited by: YellowMurdoch on Apr 18, 2010 12:20 PM