Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8080225

FileInput/OutputStream/FileChannel cleanup should be improved

    Details

    • Resolved In Build:
      b36

      Description

      FileInputStream relies on finalization to perform final closes if the FIS is not already closed.
      This results in extra work for GC that occurs in a burst. The cleanup of FileInputStreams
      should happen sooner and not contribute to overhead in GC.
      With PhantomReferences a lightweight cleanup mechanism or other suitable mechanism could be implemented.

        Issue Links

          Activity

          rriggs Roger Riggs created issue -
          rriggs Roger Riggs made changes -
          Field Original Value New Value
          Fix Version/s tbd_major [ 11972 ]
          Hide
          alanb Alan Bateman added a comment -

          The issue can be easily worked around by using Files.newInputStream instead.
          Show
          alanb Alan Bateman added a comment - The issue can be easily worked around by using Files.newInputStream instead.
          rriggs Roger Riggs made changes -
          Assignee Roger Riggs [ rriggs ]
          rriggs Roger Riggs made changes -
          Status New [ 10000 ] Open [ 1 ]
          Hide
          kbarrett Kim Barrett added a comment -
          JDK-8071507 would improve a PhantomReference-based solution in those cases where the application failed to explicitly close the stream.
          Show
          kbarrett Kim Barrett added a comment - JDK-8071507 would improve a PhantomReference-based solution in those cases where the application failed to explicitly close the stream.
          kbarrett Kim Barrett made changes -
          Link This issue relates to JDK-8071507 [ JDK-8071507 ]
          Hide
          mchung Mandy Chung added a comment -
          I agree that we should move away from finalizer and use PhantomReference.
          Show
          mchung Mandy Chung added a comment - I agree that we should move away from finalizer and use PhantomReference.
          alanb Alan Bateman made changes -
          Issue Type Bug [ 1 ] Enhancement [ 7 ]
          Subcomponent java.io [ 244 ]
          Affects Version/s 8 [ 11815 ]
          Hide
          rriggs Roger Riggs added a comment -
          The unresolvable compatibility issue is the requirement in FileInputStream and FileOutputStream finalizer methodss to call close.
          The proposed reference based cleaners can not implement anything calling close() because it would require holding a reference to the FIS/FOS which would prevent the stream from becoming phantom referenced.

          Since it is unknown/unknowable how many FIS/FOS subclasses might rely on overriding close or finalize the compatibility issue is severe. Only a long term (multiple release) restriction to deprecate or invalidate overriding would have possibility of eventually eliminating the compatibility problem.
          Show
          rriggs Roger Riggs added a comment - The unresolvable compatibility issue is the requirement in FileInputStream and FileOutputStream finalizer methodss to call close. The proposed reference based cleaners can not implement anything calling close() because it would require holding a reference to the FIS/FOS which would prevent the stream from becoming phantom referenced. Since it is unknown/unknowable how many FIS/FOS subclasses might rely on overriding close or finalize the compatibility issue is severe. Only a long term (multiple release) restriction to deprecate or invalidate overriding would have possibility of eventually eliminating the compatibility problem.
          rriggs Roger Riggs made changes -
          Link This issue csr for JDK-8187325 [ JDK-8187325 ]
          rriggs Roger Riggs made changes -
          Link This issue relates to JDK-8187631 [ JDK-8187631 ]
          rriggs Roger Riggs made changes -
          Summary FileInputStream cleanup should be improved. FileInput/OutputStream cleanup should be improved
          rriggs Roger Riggs made changes -
          Link This issue relates to CODETOOLS-7902045 [ CODETOOLS-7902045 ]
          rriggs Roger Riggs made changes -
          Link This issue relates to JDK-8189330 [ JDK-8189330 ]
          rriggs Roger Riggs made changes -
          Fix Version/s 10 [ 16302 ]
          Fix Version/s tbd_major [ 11972 ]
          rriggs Roger Riggs made changes -
          Link This issue relates to BKLG-1092 [ BKLG-1092 ]
          rriggs Roger Riggs made changes -
          Summary FileInput/OutputStream cleanup should be improved FileInput/OutputStream/FileChannel cleanup should be improved
          rriggs Roger Riggs made changes -
          Labels finalizer
          rriggs Roger Riggs made changes -
          Labels finalizer finalizer release-note=yes
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk/jdk/rev/be0df5ab3093
          User: rriggs
          Date: 2017-12-08 15:26:11 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk/jdk/rev/be0df5ab3093 User: rriggs Date: 2017-12-08 15:26:11 +0000
          hgupdate HG Updates made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolved In Build master [ 18256 ]
          Resolution Fixed [ 1 ]
          hgupdate HG Updates made changes -
          Resolved In Build master [ 18256 ] b36 [ 17434 ]
          rriggs Roger Riggs made changes -
          Link This issue relates to JDK-8194929 [ JDK-8194929 ]

            People

            • Assignee:
              rriggs Roger Riggs
              Reporter:
              rriggs Roger Riggs
            • Votes:
              0 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: