M
MG
Hi
I'm testing some client/server style socket code and running into a
strange situation... Client estblishes a socket to the server (also in
java), sends ands receives messages and all is well. Then I kill the
server program. When the client tries to send to server through the
existing socket I see a few interesting things, including one issue
that feels like a bug in java:
1. The client can write() and flush() to the socket's OutputStream
without errors. Seems weird to me since the other end of the socket is
dead.
2. The client then tries to read() a single byte of the (expected)
reply from the socket's InputStream. This is the where the Bug kicks
in... instead of getting a SocketException the CPU goes to 100%, the
vm memory usage climbs like crazy, and the an OutOfMemoryException is
thrown. This is a terrible way to handle an expected error condition.
But wait, there's more...
3. In the course of debugging this I added a bunch of
System.out.println() statements. When I did this the behavior changed
so that the read() would immediately throw a SocketException without
undue CPU or memory usage. Remove the println()'s from the code and it
goes back the 100% CPU and OutOfMemory issues.
I'm using java 1.3.1-b24 but also tried 1.4 with no change. OS is
Win2k.
Any insight would be appreciated!
Thanks
Mark
I'm testing some client/server style socket code and running into a
strange situation... Client estblishes a socket to the server (also in
java), sends ands receives messages and all is well. Then I kill the
server program. When the client tries to send to server through the
existing socket I see a few interesting things, including one issue
that feels like a bug in java:
1. The client can write() and flush() to the socket's OutputStream
without errors. Seems weird to me since the other end of the socket is
dead.
2. The client then tries to read() a single byte of the (expected)
reply from the socket's InputStream. This is the where the Bug kicks
in... instead of getting a SocketException the CPU goes to 100%, the
vm memory usage climbs like crazy, and the an OutOfMemoryException is
thrown. This is a terrible way to handle an expected error condition.
But wait, there's more...
3. In the course of debugging this I added a bunch of
System.out.println() statements. When I did this the behavior changed
so that the read() would immediately throw a SocketException without
undue CPU or memory usage. Remove the println()'s from the code and it
goes back the 100% CPU and OutOfMemory issues.
I'm using java 1.3.1-b24 but also tried 1.4 with no change. OS is
Win2k.
Any insight would be appreciated!
Thanks
Mark