Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

183
Vistas
java.net.URI cannot parse domain starting with a number

I have a URI, http://my-host.1domain:1234/path, that throws a URISyntaxException using one URI constructor:

new URI("http", /*userInfo*/null, /*host*/"my-host.1domain", 1234, "/path", /*query*/null, /*fragment*/null);

Exception in thread "main" java.net.URISyntaxException: Illegal character in hostname at index 15: http://my-host.1domain:1234/path
    at java.base/java.net.URI$Parser.fail(URI.java:2974)
    at java.base/java.net.URI$Parser.parseHostname(URI.java:3517)
    at java.base/java.net.URI$Parser.parseServer(URI.java:3358)
    at java.base/java.net.URI$Parser.parseAuthority(URI.java:3277)
    at java.base/java.net.URI$Parser.parseHierarchical(URI.java:3219)
    at java.base/java.net.URI$Parser.parse(URI.java:3175)
    at java.base/java.net.URI.<init>(URI.java:708)

but parses correctly using a different URI constructor:

// parses correctly
new URI("http", /*authority*/"my-host.1domain:1234", "/path", /*query*/null, /*fragment*/null);

Tested in OpenJDK 17.0.1. I've checked that domain names can start with a digit. So am I misusing the URI constructor or is this a bug?

(Background: the failing constructor is called from UriComponentsBuilder in Spring Web, who closed this as not-a-bug in their code)

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

In your example 1domain is a TLD (top level domain). If to look at this spec it states:

A TLD label MUST be at least two characters long and MAY be as long as 63 characters - not counting any leading or trailing periods (.). It MUST consist of only ASCII characters from the groups "letters" (A-Z), "digits" (0-9) and "hyphen" (-), and it MUST start with an ASCII "letter", and it MUST NOT end with a "hyphen". Upper and lower case MAY be mixed at random, since DNS lookups are case-insensitive.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda