dev@glassfish.java.net

Re: svn commit: r18296 - trunk/v3/core/kernel/src/main/java/com/sun/enterprise/v3/server/DomainXml.java

From: Vince Kraemer <Vince.Kraemer_at_Sun.COM>
Date: Thu, 28 Feb 2008 11:35:19 -0800

Jerome Dochez wrote:
>
> On Feb 28, 2008, at 10:29 AM, Kedar Mhaswade wrote:
> [snip]
>>
>> No, it is neither purely academic, nor is it Windows specific.
>>
>> e.g. See the following snippet:
>> -------------------------------
>> import java.io.*;
>>
>> class Foo {
>> public static void main(String ... args) throws Exception {
>> File f = new File("../f");
>> System.out.println(f.getCanonicalPath());
>> System.out.println(f.getAbsolutePath());
>> }
>> }
>> ------------------------------
>>
>> On my Mac OS X, this produces the following output:
>>
>> ------------------------------
>> /Users/kedar/Projects/f
>> /Users/kedar/Projects/Java/../f
>> ------------------------------
>>
>> Now, though these are "equivalent", I think it's related to what
>> the programmer wanted. Maybe the programmer thinks "absolutizing"
>> means the former. I see no problems with that as long as the
>> programmer is aware of the fact that getCanonicalPath() is going
>> to result in slightly lower performance because it does some
>> file system calls.

I thought that we were discussing getCanonicalFile()... not
getCanonicalPath()... but that is just a nit... the performance issue
may be worth noting, though.

If this file leaks out of the class (the code is in a private method
that returns a File), then getCanonicalFile() is probably a better choice.

If the file stays under the control of the class, getAbsoluteFile() may
be the better choice...

> I see, thanks for the clarification.
>
> Now didn't we have a bug in V1 or V2 with this getCanonical() type of
> calls. I seem to remember some escalations because it was failing with
> NFS mounted drive or something. I don't precisely remember but maybe
> someone does ?

I did not see a bug in the issuetracker that had the string
getCanonical.* in any of its description entries... I am not saying
that there wasn't an issue. I am saying it is hard to find. If there is
an issue that was caused by the use of getCanonical*(), we should
probably put that data into the issue tracker. We may need to move the
data out of the bugtraq database (after we strip any customer related
info from the entry)...

vbk