Skip to content

Set Thread Context Class Loader when instantiating configuration

Choose a tag to compare

@sbabcoc sbabcoc released this 30 Jan 18:30
· 117 commits to master since this release

In this release, we added management of the Thread Context ClassLoader to the code that instantiates the JUnitConfig class as each thread calls for it. This avoids the failure that occurs if the Apache Commons Configuration classes are loaded by the standard application class loader, but configuration class instances get created by a different class loader (e.g. - PowerMock with its Javassist class loader). This class loader mismatch would cause failures like this:

 org.apache.commons.configuration2.ex.ConfigurationRuntimeException: Incompatible result object: org.apache.commons.configuration2.PropertiesConfiguration@2f704ac9

Projects that use PowerMock and JUnit Foundation with JVM versions newer than Java 8 will run into an additional issue with logging. This is a PowerMock issue that can be resolved by configuring PowerMock to ignore the affected packages:

@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*"})

For more information: