You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@river.apache.org by Peter Firmstone <ji...@zeus.net.au> on 2011/12/11 04:12:47 UTC

PreferredClassProvider PreferredClassLoader - URI's or URL's?

Dennis,

You utilise URIClassLoader which uses URI instead of URL, I've noticed 
that it's MPL, GPL or LGPL licensed so we can't distribute it with River.

I've been looking into a subtle performance issue with 
PreferredClassProvider and PreferredClassLoader, an array of URL's are 
used as keys in a Map in PreferredClassProvider, I believe that this has 
a lot to do with the performance issues that Chris is experiencing with 
Reggie as posted on the user list.

Any thoughts about making PreferredClassProvider and 
PreferredClassLoader use URI internally?

Regards,

Peter.

Re: PreferredClassProvider PreferredClassLoader - URI's or URL's?

Posted by Peter <ji...@zeus.net.au>.
Also in PreferredClassProvider, there's an Arrays.equals comparison made on two arrays containing URL's.

It's no wonder the performance is bad, this will be causing multiple dns lookups.

I've altered PreferredClassProvider to use URI instead, URL is still used in one protected method and in PreferredClassLoader, but the annotation string is parsed as URI, then converted to URL, for Permissions and ClassLoading, however all comparisons are made using URI, to avoid DNS Lookup.

I haven't tested it yet, I'm waiting for a thunderstorm to pass, before firing up the old girl.

Will let you know the outcome, I haven't bothered about the global loader table lock at this stage, this will perform much faster now, so may not block as much.

If needed, I've got ReferenceCollection utilities, which allow the use of weak or soft references in ConcurrentMap, which will reduce remaining contention.

When it comes to ClassLoaders and classloading however you've got to be careful with concurrency.

Cheers,

Peter.

----- Original message -----
> Dennis,
>
> You utilise URIClassLoader which uses URI instead of URL, I've noticed
> that it's MPL, GPL or LGPL licensed so we can't distribute it with River.
>
> I've been looking into a subtle performance issue with
> PreferredClassProvider and PreferredClassLoader, an array of URL's are
> used as keys in a Map in PreferredClassProvider, I believe that this has
> a lot to do with the performance issues that Chris is experiencing with
> Reggie as posted on the user list.
>
> Any thoughts about making PreferredClassProvider and
> PreferredClassLoader use URI internally?
>
> Regards,
>
> Peter.


Re: PreferredClassProvider PreferredClassLoader - URI's or URL's?

Posted by Peter Firmstone <ji...@zeus.net.au>.
Hmm,

So it appears that the original author relinquishes all rights protected 
under copyright law, it's in the public domain.

In effect there is no license, there are no restrictions whatsoever.

We can get clarification from Apache Legal.

On Technical merit alone, can you see a benefit using URI's in 
PreferredClassLoader?  We can introduce it in the inheritance hierarchy 
between URLClassLoader and PreferredClassLoader without breaking 
backward compatibility if necessary.

The sun Bug ID: 6810437 states that URL should not be used as a key in 
collections and URI or the string representation should be used instead.

I've got a revised PreferredClassProvider that uses URI's in it's 
collections and Arrays internally, I'm currently testing it for any issues.

The URL javadoc states that URI should be used for parsing strings, then 
converted to URL.

Interestingly URI.toURL() checks if URI is absolute and throws an 
IllegalArgumentException if it's relative (null scheme).  This causes a 
number of malformed URL loader tests to fail, although not because they 
fail, but because the exception is not the expected failure 
MalformedURLException.  Rather than re-write all the tests, I'm catching 
the IllegalArgumentException and re-throwing it as a 
MalformedURLException, which is better, because it avoids throwing a 
runtime exception.  In effect URI.toURL() provides added protection 
against malformed URL's.  Although it may cause some failures in user 
code with codebase annotations that aren't RFC 2396 compliant, it hasn't 
caused any failures in the loader tests.  To avoid breaking existing 
code, by throwing unexpected exceptions, when a URI is instantiated by 
PreferredClassProvider internally, I'm catching URISyntaxException and 
rethrowing it as MalformedURLException with a message stating URL's must 
be RFC 2396 compliant.

URI is converted to URL for PreferredClassLoader.  I've also added a fix 
for River 265, to avoid caching Context ClassLoaders found using the 
findOriginLoader method.

While on topic, do you have any thoughts on River-147?

Cheers,

Peter.




Dennis Reedy wrote:
> Hi Peter,
>
> The URICLassLoader I use has been released into the public domain as explained here:
>
> http://creativecommons.org/licenses/publicdomain
>
> Does that still mean that you cant use it with River?
>
> Dennis
>
> On Dec 10, 2011, at 1012PM, Peter Firmstone wrote:
>
>   
>> Dennis,
>>
>> You utilise URIClassLoader which uses URI instead of URL, I've noticed that it's MPL, GPL or LGPL licensed so we can't distribute it with River.
>>
>> I've been looking into a subtle performance issue with PreferredClassProvider and PreferredClassLoader, an array of URL's are used as keys in a Map in PreferredClassProvider, I believe that this has a lot to do with the performance issues that Chris is experiencing with Reggie as posted on the user list.
>>
>> Any thoughts about making PreferredClassProvider and PreferredClassLoader use URI internally?
>>
>> Regards,
>>
>> Peter.
>>     
>
>
>   


Re: PreferredClassProvider PreferredClassLoader - URI's or URL's?

Posted by Dennis Reedy <de...@gmail.com>.
Hi Peter,

The URICLassLoader I use has been released into the public domain as explained here:

http://creativecommons.org/licenses/publicdomain

Does that still mean that you cant use it with River?

Dennis

On Dec 10, 2011, at 1012PM, Peter Firmstone wrote:

> Dennis,
> 
> You utilise URIClassLoader which uses URI instead of URL, I've noticed that it's MPL, GPL or LGPL licensed so we can't distribute it with River.
> 
> I've been looking into a subtle performance issue with PreferredClassProvider and PreferredClassLoader, an array of URL's are used as keys in a Map in PreferredClassProvider, I believe that this has a lot to do with the performance issues that Chris is experiencing with Reggie as posted on the user list.
> 
> Any thoughts about making PreferredClassProvider and PreferredClassLoader use URI internally?
> 
> Regards,
> 
> Peter.