The attached patch allows passing null into the C'tor of
ClassPropertiesConfiguration. In this case, the System class loader is
used.
Without this patch, passing null in resulted in a NPE.
Please appy, my karma seems to be missing.
Regards
Henning
Index: src/java/org/apache/commons/configuration/ClassPropertiesConfiguration.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/ClassPropertiesConfiguration.java,v
retrieving revision 1.9
diff -u -r1.9 ClassPropertiesConfiguration.java
--- src/java/org/apache/commons/configuration/ClassPropertiesConfiguration.java 24 Jun
2004 14:01:03 -0000 1.9
+++ src/java/org/apache/commons/configuration/ClassPropertiesConfiguration.java 12 Jul
2004 09:12:36 -0000
@@ -46,19 +46,26 @@
* Creates and loads an extended properties file from the Class
* Resources. Uses the class loader.
*
- * @param baseClass The class providing the FileStream.
+ * @param baseClass The class providing the FileStream. If you pass null, the
+ * system class loader will be used.
* @param resource The name of the Resource.
* @throws ConfigurationException Error while loading the properties file
*/
public ClassPropertiesConfiguration(Class baseClass, String resource) throws
ConfigurationException
{
this.baseClass = baseClass;
- // According to javadocs, getClassLoader() might return null
- // if it represents the "bootstrap class loader"
- // Use the System class loader in this case.
- classLoader = (baseClass.getClassLoader() == null)
- ? ClassLoader.getSystemClassLoader()
- : baseClass.getClassLoader();
+
+ // According to javadocs, getClassLoader() might return null
+ // if it represents the "bootstrap class loader"
+ // Use the System class loader in this case.
+ if (baseClass != null && baseClass.getClassLoader() != null)
+ {
+ classLoader = baseClass.getClassLoader();
+ }
+ else
+ {
+ classLoader = ClassLoader.getSystemClassLoader();
+ }
setIncludesAllowed(true);
try
@@ -83,8 +90,11 @@
{
InputStream resource = null;
- //First try to load from within the package of the provided class
- resource = baseClass.getResourceAsStream(resourceName);
+ if (baseClass != null)
+ {
+ // First try to load from within the package of the provided class
+ resource = baseClass.getResourceAsStream(resourceName);
+ }
if (resource == null)
{
--
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH
[EMAIL PROTECTED] +49 9131 50 654 0 http://www.intermeta.de/
RedHat Certified Engineer -- Jakarta Turbine Development -- hero for hire
Linux, Java, perl, Solaris -- Consulting, Training, Development
"Fighting for one's political stand is an honorable action, but re-
fusing to acknowledge that there might be weaknesses in one's
position - in order to identify them so that they can be remedied -
is a large enough problem with the Open Source movement that it
deserves to be on this list of the top five problems."
-- Michelle Levesque, "Fundamental Issues with
Open Source Software Development"
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]