jersey
  1. jersey
  2. JERSEY-1800

UriBuilder#uri("") throws NoSuchElementException

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0-m13
    • Fix Version/s: 2.0-rc1, 2.0
    • Component/s: core
    • Labels:
      None

      Description

      String first = "news:comp.lang.java";
      String second = "";
      UriBuilder.fromUri(new URI(first)).uri(second);
      

      throws:

      ERROR: java.util.NoSuchElementException
      at org.glassfish.jersey.uri.internal.CharacterIterator.next(CharacterIterator.java:80)
      at org.glassfish.jersey.uri.internal.UriParser.parse(UriParser.java:158)
      at org.glassfish.jersey.uri.internal.JerseyUriBuilder.uri(JerseyUriBuilder.java:195)
      at org.glassfish.jersey.uri.internal.JerseyUriBuilder.uri(JerseyUriBuilder.java:69)

      But the javadoc says:

      Throws:
      java.lang.IllegalArgumentException - if uriTemplate is not a valid URI template or is null.

        Issue Links

          Activity

          Hide
          Marek Potociar added a comment - - edited

          The fix has been sent for review.

          Note that the fixed code will not throw any exception, which is a valid behavior as scheme-specific part of URI can be empty according to URI RFC 3986. However, even though the URI is valid according to RFC 3986, it is not possible to create a java.net.URI instance with an empty scheme-specific part, so any attempt to invoke a build() method on such UriBuilder would fail with an UriBuilderException exception.

          Show
          Marek Potociar added a comment - - edited The fix has been sent for review. Note that the fixed code will not throw any exception, which is a valid behavior as scheme-specific part of URI can be empty according to URI RFC 3986. However, even though the URI is valid according to RFC 3986, it is not possible to create a java.net.URI instance with an empty scheme-specific part, so any attempt to invoke a build() method on such UriBuilder would fail with an UriBuilderException exception.

            People

            • Assignee:
              Marek Potociar
              Reporter:
              jan.supol
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours
                2h