You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Rene Scheibe <re...@tngtech.com> on 2010/09/09 17:20:06 UTC

Bug in UtilUrl.fromResource() ?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Just a short question. When resolving the URL for a resource via
UtilUrl.fromResource(String resourceName, ClassLoader loader) why is it
implemented that the most specific match is the last one? See below?

if (url == null) url = loader.getResource(resourceName);
if (url == null) url = loader.getResource(resourceName + ".properties");

This results in a problem, when eg. calling
UtilProperties.getPropertyValue("catalog", "image.server.path").
Scenario: I have another jar in the classpath that contains a "catalog"
folder. I expect to get the property from catalog.properties but the
result is a "catalog" URL from my other jar, which does not include
anything useful and results in NullPointerExceptions in OFBiz.

Regards,
René
- -- 
René Scheibe * rene.scheibe@tngtech.com
TNG Technology Consulting GmbH, Betastr. 13a, 85774 Unterföhring
Geschäftsführer: Henrik Klagges, Gerhard Müller, Christoph Stock
Sitz: Unterföhring * Amtsgericht München * HRB 135082
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkyI+yYACgkQUXs9EHvIuCqawwCeInqjKiFSv4mXAJMYbz/bMXY1
978AnjUS4sN334TCgAdoYoQvURz5smFN
=IB2w
-----END PGP SIGNATURE-----

Re: Bug in UtilUrl.fromResource() ?

Posted by Adam Heath <do...@brainfood.com>.
On 09/09/2010 10:20 AM, Rene Scheibe wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Just a short question. When resolving the URL for a resource via
> UtilUrl.fromResource(String resourceName, ClassLoader loader) why is it
> implemented that the most specific match is the last one? See below?
>
> if (url == null) url = loader.getResource(resourceName);
> if (url == null) url = loader.getResource(resourceName + ".properties");
>
> This results in a problem, when eg. calling
> UtilProperties.getPropertyValue("catalog", "image.server.path").
> Scenario: I have another jar in the classpath that contains a "catalog"
> folder. I expect to get the property from catalog.properties but the
> result is a "catalog" URL from my other jar, which does not include
> anything useful and results in NullPointerExceptions in OFBiz.

The bug here is not the ordering of those lines, but the calling code 
requesting just 'catalog'.  The calling code should directly request 
'catalog.properties'.

There was a similiar bug years(ages) ago, where calling code requested 
'security', instead of 'security.properties'.  As you can imagine, 
'security' is a rather general term, and it clashed with other locations.