|
|
|
Re: [CDO] Official Releases [message #1833088 is a reply to message #1833073] |
Fri, 02 October 2020 05:11 |
|
This issue is annoying but also a bit interesting. I found out the following:
According to RFC2396 (URI Generic Syntax), section 3.2.2. (Server-based Naming Authority), the hostname MUST NOT contain underscore characters:
hostport = host [ ":" port ]
host = hostname | IPv4address
hostname = *( domainlabel "." ) toplabel [ "." ]
domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum
toplabel = alpha | alpha *( alphanum | "-" ) alphanum
IPv4address = 1*digit "." 1*digit "." 1*digit "." 1*digit
port = *digit
This is in line with RFC1034 (Domain Concepts and Facilities), section 3.5. (Preferred name syntax):
<domain> ::= <subdomain> | " "
<subdomain> ::= <label> | <subdomain> "." <label>
<label> ::= <letter> [ [ <ldh-str> ] <let-dig> ]
<ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str>
<let-dig-hyp> ::= <let-dig> | "-"
<let-dig> ::= <letter> | <digit>
<letter> ::= any one of the 52 alphabetic characters A through Z in upper case and a through z in lower case
<digit> ::= any one of the ten digits 0 through 9
I think we can conclude that your hostname "dev_cdo-server" is INVALID because it contains an underscore character (and not because it contains a hyphen character). For example, "dev-cdo-server" is a valid hostname. In case you're not happy with my wording "invalid", think of it as "invalid w.r.t the aforementioned RFCs" ;-)
The java.net.URI class is very strict about RFC2396, so I wondered why we see no exception being thrown when you pass in your hostname with the underscore character. The reason is RFC2396, section 3.2.1. (Registry-based Naming Authority):
authority = server | reg_name
reg_name = 1*( unreserved | escaped | "$" | "," |
";" | ":" | "@" | "&" | "=" | "+" )
I.e., your complete URI (with the underscore character) is not invalid. It's just not a "Server-based Naming Authority", but falls back to a "Registry-based Naming Authority". In fact java.net.URI.Parser.parseHostname() internally throws a URISyntaxException with the expected message:
Exception in thread "main" java.net.URISyntaxException: Illegal character in hostname at index 9: tcp://dev_cdo-server:8000
at java.base/java.net.URI$Parser.fail(URI.java:2915)
at java.base/java.net.URI$Parser.parseHostname(URI.java:3450)
at java.base/java.net.URI$Parser.parseServer(URI.java:3299)
at java.base/java.net.URI$Parser.parseAuthority(URI.java:3218)
at java.base/java.net.URI$Parser.parseHierarchical(URI.java:3160)
at java.base/java.net.URI$Parser.parse(URI.java:3116)
Because of the section 3.2.1. loophole this exception is caught higher up in the call chain. I learned now that you can explicitly provoke this exception with the following code:
java.net.URI uri = new java.net.URI("tcp://dev_cdo-server:8000");
uri.parseServerAuthority();
Go figure!
BTW., according to RFC2396, section 1.2. (URI, URL, and URN), URLs are a subset of URIs. It just happens that Java's parser for URLs, java.net.URLStreamHandler.parseURL(), is much more lax than its URI counterpart.
You're right that your problem is caused by this change in Net4j: https://github.com/eclipse/cdo/commit/ef0b96be8946faa345d473c5f951d8debe540a0c#diff-d7b8a68a43c66f54eb0005c5cfa0d786L341 . Notice the former "//TODO Don't use URL". I still think that it's better to use java.net.URI for parsing because it doesn't rely on a registered protocol/URLStreamHandler. But I can offer to provide a system property that you can use to switch back to the legacy behavior, in case you can't/don't want to change your hostname to be RFC2396-compliant. Please submit a bugzilla then.
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
Powered by
FUDForum. Page generated in 0.03270 seconds