On 19.09.2007 3:12 Uhr, Carsten Ziegeler wrote:
This code was updated on 20.07.2007 with the upgrade to sourceresolve
2.2.3 (rev 557982 and 557994 [1, 2] and 557984 on 2.1 [3]). Since then
it must be failing. From what I get it's now failing for Windows with 2
slashes while the test expects 3. Linux/Mac OS X seems to work since
they have 3 slashes now. Before it was the other way around, Windows
worked with 2, Linux/Mac OS X failed with 1.
From the implementation [4] this is pretty clear:
uri = file.toURL().toExternalForm();
// toExternalForm() is buggy, see e.g.
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4924415
// therefore we check if file: is followed by just one slash
// TODO when we move to JDK 1.4+, we should use
file.toURI().toASCIIString() instead.
if ( uri.length() > 6 && uri.startsWith("file:/") && uri.charAt(6) != '/' )
{
uri = "file:///" + uri.substring(6);
}
It just adds 3 slashes instead of 2 as it is supposed to do. So we
probably need a sourceresolve 2.2.4. Is this likely to happen fast or do
we need to revert the test case to not fail for the moment? Anyway, I'm
going to change the test case back to 2 slashes. sourceresolve's own
test case also only checks for 2 slashes [5].
Hmm, I'm still not sure what is wrong: the sourceresolver impl or this
test? After the disaster of the 2.2.2 release breaking this stuff, I
tested the 2.2.3 release on both windows and macos x and it did work for
me. I also tested Cocoon 2.1.x and trunk with it and it worked - both
failed with the 2.2.2 version.
So, perhaps its just the test case which is wrong?
Without the above condition the uri came out with 2 slashes on Windows
and 1 slash on other os. With the condition you actually replace file:/
with file:/// so you eventually have 3 slashes in case there was only
one before.
If you had a successful run on Windows (did it run through the condition
or had it 3 slashes from the beginning??) there must be a different
behavior between Windows versions as well. But can you place
double-check that? On Windows you should really get exactly 2 slashes.
That's why I thought the code needs to be fixed and not the test case.
The uri should always have 2 slashes.
Joerg