-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.0
-
x86
-
windows_2000
Name: nt126004 Date: 06/26/2002
FULL PRODUCT VERSION :
C:\temp>java -version
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
When resolving the same document reference "" (the empty
string) against a hierarchical URI the last component of
the URI is lost.
This is inconsistent with the treatment of the other sort
of same document reference "#foo" in which the full URI is
preserved (correctly in my view).
Note the term 'same document reference' is used in RFC 2396.
See:
http://lists.w3.org/Archives/Public/uri/2002Apr/att-0025/01-uri.html
and discussion therein.
--------------------------
[[[[
4.2. Same-document References
A URI reference that does not contain a URI is a reference to the
current document. In other words, an empty URI reference within a
document is interpreted as a reference to the start of that document,
and a reference containing only a fragment identifier is a reference
to the identified fragment of that document. Traversal of such a
reference should not result in an additional retrieval action.
However, if the URI reference occurs in a context that is always
intended to result in a new request, as in the case of HTML's FORM
element, then an empty URI reference represents the base URI of the
current document and should be replaced by that URI when transformed
into a request.
]]]]
----------------------------
I would suggest the word "violate" is a little strong. This behaviour of
java.net.URI is at a point where the RFC is difficult to interpret, to
say the least.
The suggested behaviour above (the "current document") is very difficult
to read coherently in the java.net.URI case, but the RFC views "" and
"#foo" as closely related (see quoted text above). The RFC see both as
relating to the current document, which in the context of the
java.net.URI.resolve() method is best represented by the current object.
With that reading of both the RFC and java.net.URI intent then the
behaviour identified in my report is a bug.
Try the closely related tests:
Invoke
java -cp . Test "http://example.org/dir/file" "#foo"
and
java -cp . Test "http://example.org/dir/file#frag" "#foo"
EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected and actual results are in both cases
http://example.org/dir/file#foo
given that both "" and "#foo" are same document references then the
resulting base URI should be the same in all four test cases.
(At some level there is a design error in not treating ""
along with "#foo" but in designing an algorithm for
the "#foo" case separately from the "" case)
Both types of same document references "" are used extensively in DAML+OIL.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile 1 line program attached:
Invoke
java -cp . Test "http://example.org/dir/file" ""
and
java -cp . Test "http://example.org/dir/file#frag" ""
EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected results are in both cases
http://example.org/dir/file
Actual results in both cases are
http://example.org/dir/
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
/*
Use the new wonderful URI class that gets
very nearly everything right!
If only a reissue of RFC 2396 endorsed this
class.
*/
import java.net.URI;
public class Test {
static public void main(String args[]) {
System.out.println(URI.create(args[0]).resolve(args[1]));
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
Specially check for this case in invoking code,
replace "" by "#" and then remove "#" manually later.
(Review ID: 148122)
======================================================================
- duplicates
-
JDK-6920138 URI not handling empty reference resolution
- Open
- relates to
-
JDK-6920138 URI not handling empty reference resolution
- Open