Skip to content

Ignore an empty port value in URI parsingΒ #37117

Closed

Description

@rstoyanchev

The ABNF rules of RFC 3986 permit a host with an ":" delimiter and an empty port, and section 3.2.3 says:

URI producers and normalizers should omit the port component
and its ":" delimiter if port is empty or if its value would
be the same as that of the scheme's default.

Currently RfcUrlParser captures an empty String as a port value, and UriComponentsBuilder accepts an empty String, but results in an IllegalStateException if the port is accessed with UriComponents#getPort.

By comparison both WhatWgUrlParser and java.net.URI ignore an empty port value and treat it as missing. We should explicitly handle that case in RfcUrlParser and in UriComponentsBuilder to the same effect.

Activity

  1. added this to the 7.0.9 milestone on Aug 7, 2026
  2. self-assigned this
    on Aug 7, 2026
  3. added
    in: webIssues in web modules (web, webmvc, webflux, websocket)
    on Aug 7, 2026
  4. github-actions commented on Aug 7, 2026

    @github-actions
    Contributor

    Fixed via 11bb7b5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions