[kepler-dev] [Fwd: Re: kepler/src/util URLToLocalFile.java]
Christopher Brooks
cxh at eecs.berkeley.edu
Thu Feb 2 17:55:46 PST 2006
Ok, this is fixed.
I created a test that creates a URL by calling
new URL("http", null, /foo);
and then pass the string to ptolemy.util.FileUtilities.nameToURL()
and I was getting http:/foo back.
I modified the code so I now get http://foo back.
The test is:
test FileUtilities-8.7 {nameToURL: with http:/www} {
set url [java::new java.net.URL http [java::null] /www]
set file1 [java::call ptolemy.util.FileUtilities nameToURL \
[$url toString] [java::null] [java::null]]
list [$file1 toString]
} {http://www}
Hopefully this will not break anything - it seems pretty safe?
BTW - Perhaps URLToLocalFile should call nameToURL so that it will look
in the classpath etc?
_Christopher
--------
Well, it seems I cannot reproduce the problem Efrat was having. Maybe
that was a data problem. However, even with the test workflow, and the
previous revision of URLToLocalFile, I cannot reproduce the problem.
Kevin
>
> Dan,
>
> I was talking to Efrat a while ago, and I think this fix actually
> covers up a bug in ptII's ptolemy.util.FileUtilities.nameToURL() which
> appears to add an extra "/" to the string, which then makes the name
> look like this: "http:///www". What this really indicates to Java
> when converted to a URL, is protocol = http, host = null (localhost),
> file = "/www", then if this URL is converted back into a string you
> get this: "http:/www" because of the null host.
>
> I've cc'd the ptolemy-hackers list because they might should look at
> this. The bug was introduced in r1.28 of that file.
>
> Kevin
>
> Daniel Higgins wrote:
>> +
>> +// jan2706: fix the "http:/www..." problem:
>> + try {
>> + String fixedUrlAsString = +
>> url.toString().replaceFirst("(https?:)//?", "$1//" );
>> + url = new URL( fixedUrlAsString );
>> + } catch( Exception e ) {
>> + System.out.println( "Badly formed url exception: " + e );
>> + }
>> +
>> +//System.out.println( "URLToLocalFile2:
>> url.toString()="+url.toString() );
>>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Kepler-dev mailing list
> Kepler-dev at ecoinformatics.org
> http://mercury.nceas.ucsb.edu/ecoinformatics/mailman/listinfo/kepler-dev
>
---------------------------------------------------------------------------
-
Posted to the ptolemy-hackers mailing list. Please send administrative
mail for this list to: ptolemy-hackers-request at ptolemy.eecs.berkeley.edu
--------
More information about the Kepler-dev
mailing list