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

XMLWordPrintable

    • Type: Bug
    • Resolution: Incomplete
    • Priority: P4
    • None
    • Affects Version/s: 7u51
    • Component/s: 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!

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

              Created:
              Updated:
              Resolved: