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

java.net.URI does not parse empty authority correctly.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 8u25, 8u40
    • core-libs
    • x86
    • os_x

      FULL PRODUCT VERSION :
      java version "1.8.0_25"
      Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
      Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Darwin spotify-mzeo-osx.local 14.1.0 Darwin Kernel Version 14.1.0: Thu Feb 26 19:26:47 PST 2015; root:xnu-2782.10.73~1/RELEASE_X86_64 x86_64

      A DESCRIPTION OF THE PROBLEM :
      Uri:s are not parsed according to RFC 2396 BNF.

      Appendix A (Collected BNF for URI) of RFC 2396 has authority being optional (server is optional empty). net_path should parse "//" as server = "" without a abs_path part.





      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run:

      import java.net.URI;
      class main {
        public static void main(final String[] args) throws Exception {
          new URI("s://");
        }
      }


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Not throw exception.

      ACTUAL -
      Throws java.net.URISyntaxException.


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "main" java.net.URISyntaxException: Expected authority at index 4: s://
      at java.net.URI$Parser.fail(URI.java:2848)
      at java.net.URI$Parser.failExpecting(URI.java:2854)
      at java.net.URI$Parser.parseHierarchical(URI.java:3102)
      at java.net.URI$Parser.parse(URI.java:3053)
      at java.net.URI.<init>(URI.java:588)
      at main.main(main.java:4)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.net.URI;
      class main {
        public static void main(final String[] args) throws Exception {
          new URI("s://");
        }
      }


      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Treat schema as path.


            dfuchs Daniel Fuchs
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: