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

FileInputStream does not close file after using it's close method

XMLWordPrintable

    • x86_64
    • windows_7

      FULL PRODUCT VERSION :
      JDK 8 Update 40 (64-Bit)
      JRE 8 Update 111 (64-Bit)

      ADDITIONAL OS VERSION INFORMATION :
      ver 64Bit

      A DESCRIPTION OF THE PROBLEM :
      If an InputStream (or any other Stream) is used to open a file in Java, the stream won´t let the file free. Even if the close() - Method is called. I found that out when I tried to delete the affected file.

      To solve this, one must close, set the stream object equals null and activate the „Garbadge Collector“ manually to get rid of the stream objects.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Copy files and folders to a another location using FileInputStream and FileOutputStream
      2. zip them using
           import java.util.zip.ZipEntry;
           import java.util.zip.ZipOutputStream;
      3. Delete old files and folders
      4. Problem will occur!!!

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Step 3 should work because I closed all Streams using the close-Method.
      ACTUAL -
      Only 3 of 10 files were deleted.

      REPRODUCIBILITY :
      This bug can be reproduced always.

            bpb Brian Burkhalter
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: