Here is the evaluation:
The observed behavior change was caused by the fix for JDK-7105952 (Improve
finalisation for FileInputStream/FileOutputStream/RandomAccessFile).
Without that fix, finalizer's code of a Input/Output Stream could close the
file descriptor while it was still in use by another stream (e.g. see
That fix for JDK-7105952 has caused a regression, similar to what the
submitter is observing: JDK-7181793 (Socket getOutputStream create streams
that cannot be GC'ed until Socket is closed).
The real reason of that regression was that the method
Socket.getOutputStream() created a new FileDescriptor object (wrapping the
same native file descriptor) each time when called. This caused the list of
the "parents" of the FileDescriptor to grow.
Please also see the comments with additional details:
It appears that the application needs to memorize created ReceiveSocketInputStream and
ReceiveSocketOutputStream that reference given FileDescriptor and reuse them
rather create new each time.