> From: André Warnier [mailto:[email protected]]
> public void close()
> throws SomeException
> {
> putEndRequest();
> flush();
> socket = null;
> }
> flush() being another function which reads the socket until there's
> nothing left to read, and throws away the result.
> "socket" is a property of the object created by this class, obtained
> somewhere else from a java.net.Socket object.
> Looking at that code above, it is obvious that "socket" is open, until
> it is set to null, without previously doing a socket.close().
> I don't know Java enough to know if this alone could cause that socket
> to be lingering until the GC, but I kind of suspect so.
Nice piece of detective work, André! Yes, that code's broken - the socket's
not referenced but not closed, so it will stay open until a GC tidies it up.
$deity only knows what the original developer was thinking when they wrote that.
- Peter
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]