You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by oh...@apache.org on 2006/04/10 17:53:50 UTC
svn commit: r392979 - in /jakarta/commons/proper/configuration/trunk:
src/java/org/apache/commons/configuration/ConfigurationUtils.java
src/test/org/apache/commons/configuration/TestConfigurationUtils.java
xdocs/changes.xml
Author: oheger
Date: Mon Apr 10 08:53:48 2006
New Revision: 392979
URL: http://svn.apache.org/viewcvs?rev=392979&view=rev
Log:
Added check for null TCCL; fix for issue 39169
Modified:
jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationUtils.java
jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestConfigurationUtils.java
jakarta/commons/proper/configuration/trunk/xdocs/changes.xml
Modified: jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationUtils.java?rev=392979&r1=392978&r2=392979&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationUtils.java (original)
+++ jakarta/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/ConfigurationUtils.java Mon Apr 10 08:53:48 2006
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2005 The Apache Software Foundation.
+ * Copyright 2001-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
@@ -375,11 +375,14 @@
if (url == null)
{
ClassLoader loader = Thread.currentThread().getContextClassLoader();
- url = loader.getResource(name);
-
- if (url != null)
+ if (loader != null)
{
- log.debug("Configuration loaded from the context classpath (" + name + ")");
+ url = loader.getResource(name);
+
+ if (url != null)
+ {
+ log.debug("Configuration loaded from the context classpath (" + name + ")");
+ }
}
}
Modified: jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestConfigurationUtils.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestConfigurationUtils.java?rev=392979&r1=392978&r2=392979&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestConfigurationUtils.java (original)
+++ jakarta/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/TestConfigurationUtils.java Mon Apr 10 08:53:48 2006
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2004 The Apache Software Foundation.
+ * Copyright 2001-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
@@ -182,5 +182,20 @@
assertEquals(reference, ConfigurationUtils.getFile(directory.getAbsolutePath(), reference.getName()));
assertEquals(reference, ConfigurationUtils.getFile(directory.toURL().toString(), reference.getName()));
assertEquals(reference, ConfigurationUtils.getFile("invalid", reference.toURL().toString()));
+ }
+
+ public void testLocateWithNullTCCL() throws Exception
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader(null);
+ assertNull(ConfigurationUtils.locate("abase", "aname"));
+ assertNotNull(ConfigurationUtils.locate("test.xml"));
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
}
}
Modified: jakarta/commons/proper/configuration/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/configuration/trunk/xdocs/changes.xml?rev=392979&r1=392978&r2=392979&view=diff
==============================================================================
--- jakarta/commons/proper/configuration/trunk/xdocs/changes.xml (original)
+++ jakarta/commons/proper/configuration/trunk/xdocs/changes.xml Mon Apr 10 08:53:48 2006
@@ -23,6 +23,10 @@
<body>
<release version="1.3-SNAPSHOT" date="in SVN">
+ <action dev="oheger" type="update" issue="39169">
+ Loading of file-based configurations no longer throws a NullPointerException
+ in setups where the thread context class loader is not set.
+ </action>
<action dev="oheger" type="update">
The dependency to dom4j was removed; it was only used by two test classes,
which have been re-written.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org