Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda