OSDN Git Service

b/2663512: "java.io.IOException: SSL shutdown failed.: Ok" shouldn't dump a stacktrace
authorBrian Carlstrom <bdc@google.com>
Fri, 7 May 2010 16:58:15 +0000 (09:58 -0700)
committerBrian Carlstrom <bdc@google.com>
Fri, 7 May 2010 17:08:49 +0000 (10:08 -0700)
commit264952afbf3986a2af4c2fa6b8daaed04f34fee8
treedae5d8fc4639b17eee5e5bbee61f053871726f9d
parent818164b87a9c08a938c371d8b47987a3af06d6f6
b/2663512: "java.io.IOException: SSL shutdown failed.: Ok" shouldn't dump a stacktrace

Gutted OpenSSLSocketImpl finalizer. The comment from the code
(excepted below) explains in detail the trouble of having the
finalizer do anything more than touch its the instances own state due
to unpredictable order of finalization and the future possability of
parallel finalization.

        /*
         * Just worry about our own state. Notably we do not try and
         * close anything. The SocketImpl, either our own
         * PlainSocketImpl, or the Socket we are wrapping, will do
         * that. This might mean we do not properly SSL_shutdown, but
         * if you want to do that, properly close the socket yourself.
         *
         * The reason why we don't try to SSL_shutdown is that there
         * can be a race between finalizers where the PlainSocketImpl
         * finalizer runs first and closes the socket. However, in the
         * meanwhile, the underlying file descriptor could be reused
         * for another purpose. If we call SSL_shutdown after that, the
         * underlying socket BIOs still have the older file descriptor
         * and will write the close notify to some unsuspecting
         * reader.
         */

Tested extensively in mainline with existing tests.xnet.AllTests as
well as new javax.net.ssl tests. Sanity tested in froyo with
tests.xnet.AllTests and browser testing.

Change-Id: I85e0e086b43b2ad79304f2cf42721d09cc41a5f4
libcore/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java