A DESCRIPTION OF THE PROBLEM :
The section "Operations on URI instances" states:
Relativization, finally, is the inverse of resolution: For any two normalized URIs u and v,
u.relativize(u.resolve(v)).equals(v) and
u.resolve(u.relativize(v)).equals(v) .
This is not true for at least the following two cases:
1. Base URI (u) that doesn't end with an empty segment:
URI u = new URI("http://a.ch/a")
URI v = new URI("http://a.ch/a/b")
u.resolve(u.relativize(v))
// "http://a.ch/b" != "http://a.ch/a/b"
u.relativize(u.resolve(v))
// "b" != "http://a.ch/a/b"
2. Target URI (v) that contains top-level ".." segments:
URI u = new URI("http://a.ch/a")
URI v = new URI("../b")
u.resolve(u.relativize(v))
// "http://a.ch/../b" != "../b"
u.relativize(u.resolve(v))
// "http://a.ch/../b" != "../b"
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
1. No invariant about relativization and resolution
2. Proper documentation about relativization
- how it handles non-empty segments at end of base path
- that relativization will never introduce ".." segments
ACTUAL -
Relativization, finally, is the inverse of resolution: For any two normalized URIs u and v,
u.relativize(u.resolve(v)).equals(v) and
u.resolve(u.relativize(v)).equals(v) .
URL OF FAULTY DOCUMENTATION :
http://docs.oracle.com/javase/7/docs/api/java/net/URI.html
The section "Operations on URI instances" states:
Relativization, finally, is the inverse of resolution: For any two normalized URIs u and v,
u.relativize(u.resolve(v)).equals(v) and
u.resolve(u.relativize(v)).equals(v) .
This is not true for at least the following two cases:
1. Base URI (u) that doesn't end with an empty segment:
URI u = new URI("http://a.ch/a")
URI v = new URI("http://a.ch/a/b")
u.resolve(u.relativize(v))
// "http://a.ch/b" != "http://a.ch/a/b"
u.relativize(u.resolve(v))
// "b" != "http://a.ch/a/b"
2. Target URI (v) that contains top-level ".." segments:
URI u = new URI("http://a.ch/a")
URI v = new URI("../b")
u.resolve(u.relativize(v))
// "http://a.ch/../b" != "../b"
u.relativize(u.resolve(v))
// "http://a.ch/../b" != "../b"
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
1. No invariant about relativization and resolution
2. Proper documentation about relativization
- how it handles non-empty segments at end of base path
- that relativization will never introduce ".." segments
ACTUAL -
Relativization, finally, is the inverse of resolution: For any two normalized URIs u and v,
u.relativize(u.resolve(v)).equals(v) and
u.resolve(u.relativize(v)).equals(v) .
URL OF FAULTY DOCUMENTATION :
http://docs.oracle.com/javase/7/docs/api/java/net/URI.html
- csr for
-
JDK-8291462 Invariants about java.net.URI resolve and relativize are wrong
-
- Closed
-