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

Class.getResourceAsStream("/directory/") returns broken InputStream

    • Icon: Bug Bug
    • Resolution: Incomplete
    • Icon: P4 P4
    • None
    • 7u51
    • core-libs
    • x86
    • generic

      FULL PRODUCT VERSION :


      ADDITIONAL OS VERSION INFORMATION :
      Mac OS X 10.9.2

      A DESCRIPTION OF THE PROBLEM :
      I'm calling Class.getResourceAsStream("/directory/") where I'm running from a jar file contains a non-empty directory named /directory.



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create an application that runs from a jar file containing a directory named /directory/. Call Class.getResourceAsStream("/directory/") and close the returned stream.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      It doesn't make sense to get an InputStream for a directory. This method should return null.


      ACTUAL -
      The method returns a non-null InputStream. But calling operations on that InputStream (like close()) throws a NullPointerException.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      Catch the NullPointerException!

          Loading...
          Uploaded image for project: 'JDK'
          1. JDK
          2. JDK-8039169

          Class.getResourceAsStream("/directory/") returns broken InputStream

            • Icon: Bug Bug
            • Resolution: Incomplete
            • Icon: P4 P4
            • None
            • 7u51
            • core-libs
            • x86
            • generic

              FULL PRODUCT VERSION :


              ADDITIONAL OS VERSION INFORMATION :
              Mac OS X 10.9.2

              A DESCRIPTION OF THE PROBLEM :
              I'm calling Class.getResourceAsStream("/directory/") where I'm running from a jar file contains a non-empty directory named /directory.



              STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
              Create an application that runs from a jar file containing a directory named /directory/. Call Class.getResourceAsStream("/directory/") and close the returned stream.

              EXPECTED VERSUS ACTUAL BEHAVIOR :
              EXPECTED -
              It doesn't make sense to get an InputStream for a directory. This method should return null.


              ACTUAL -
              The method returns a non-null InputStream. But calling operations on that InputStream (like close()) throws a NullPointerException.

              REPRODUCIBILITY :
              This bug can be reproduced always.

              CUSTOMER SUBMITTED WORKAROUND :
              Catch the NullPointerException!

                    Unassigned Unassigned
                    webbuggrp Webbug Group
                    Votes:
                    0 Vote for this issue
                    Watchers:
                    4 Start watching this issue

                      Created:
                      Updated:
                      Resolved:

                        Unassigned Unassigned
                        webbuggrp Webbug Group
                        Votes:
                        0 Vote for this issue
                        Watchers:
                        4 Start watching this issue

                          Created:
                          Updated:
                          Resolved: