--- old/src/share/classes/java/io/FileInputStream.java Thu Sep 8 17:21:20 2011 +++ new/src/share/classes/java/io/FileInputStream.java Thu Sep 8 17:21:19 2011 @@ -56,16 +56,6 @@ private final Object closeLock = new Object(); private volatile boolean closed = false; - private static final ThreadLocal runningFinalize = - new ThreadLocal<>(); - - private static boolean isRunningFinalize() { - Boolean val; - if ((val = runningFinalize.get()) != null) - return val.booleanValue(); - return false; - } - /** * Creates a FileInputStream by * opening a connection to an actual file, @@ -319,10 +309,10 @@ int useCount = fd.decrementAndGetUseCount(); /* - * If FileDescriptor is still in use by another stream, the finalizer + * If FileDescriptor is still in use by another stream, we * will not close it. */ - if ((useCount <= 0) || !isRunningFinalize()) { + if (useCount <= 0) { close0(); } } @@ -391,18 +381,7 @@ */ protected void finalize() throws IOException { if ((fd != null) && (fd != FileDescriptor.in)) { - - /* - * Finalizer should not release the FileDescriptor if another - * stream is still using it. If the user directly invokes - * close() then the FileDescriptor is also released. - */ - runningFinalize.set(Boolean.TRUE); - try { close(); - } finally { - runningFinalize.set(Boolean.FALSE); - } } } }