Author: manik.surtani(a)jboss.com
Date: 2008-02-07 12:47:59 -0500 (Thu, 07 Feb 2008)
New Revision: 5325
Modified:
core/trunk/src/main/java/org/jboss/cache/factories/TransactionManagerFactory.java
core/trunk/src/main/java/org/jboss/cache/factories/XmlConfigurationParser.java
core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/AsyncReplTest.java
Log:
Added some null checks
Modified:
core/trunk/src/main/java/org/jboss/cache/factories/TransactionManagerFactory.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/factories/TransactionManagerFactory.java 2008-02-07
15:45:29 UTC (rev 5324)
+++
core/trunk/src/main/java/org/jboss/cache/factories/TransactionManagerFactory.java 2008-02-07
17:47:59 UTC (rev 5325)
@@ -30,7 +30,9 @@
{
try
{
- Class clazz =
Thread.currentThread().getContextClassLoader().loadClass(configuration.getTransactionManagerLookupClass());
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if (cl == null) cl = getClass().getClassLoader();
+ Class clazz =
cl.loadClass(configuration.getTransactionManagerLookupClass());
lookup = (TransactionManagerLookup) clazz.newInstance();
}
catch (Exception e)
Modified: core/trunk/src/main/java/org/jboss/cache/factories/XmlConfigurationParser.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/factories/XmlConfigurationParser.java 2008-02-07
15:45:29 UTC (rev 5324)
+++
core/trunk/src/main/java/org/jboss/cache/factories/XmlConfigurationParser.java 2008-02-07
17:47:59 UTC (rev 5325)
@@ -193,7 +193,8 @@
protected InputStream getAsInputStreamFromClassLoader(String filename)
{
- InputStream is =
Thread.currentThread().getContextClassLoader().getResourceAsStream(filename);
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ InputStream is = cl == null ? null : cl.getResourceAsStream(filename);
if (is == null)
{
// check system class loader
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2008-02-07
15:45:29 UTC (rev 5324)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2008-02-07
17:47:59 UTC (rev 5325)
@@ -134,7 +134,7 @@
else
{
UnmarshalledReferences refMap = useRefs ? new UnmarshalledReferences() : null;
- Object retValue = unmarshallObject(in, defaultClassLoader, refMap);
+ Object retValue = unmarshallObject(in, defaultClassLoader, refMap, false);
if (trace) log.trace("Unmarshalled object " + retValue);
return retValue;
}
@@ -200,11 +200,11 @@
{
if (log.isDebugEnabled())
log.debug("Region does not exist for Fqn " + regionFqn + " -
not using a context classloader.");
- retValue = unmarshallObject(in, defaultClassLoader, refMap);
+ retValue = unmarshallObject(in, defaultClassLoader, refMap, false);
}
else
{
- retValue = unmarshallObject(in, region.getClassLoader(), refMap);
+ retValue = unmarshallObject(in, region.getClassLoader(), refMap, true);
// only set this if this is an incoming method call and not a return value.
if (!isReturnValue(retValue)) regionForCall.set(regionFqn);
@@ -517,7 +517,7 @@
// --------- Unmarshalling methods
- private Object unmarshallObject(ObjectInputStream in, ClassLoader loader,
UnmarshalledReferences refMap) throws Exception
+ private Object unmarshallObject(ObjectInputStream in, ClassLoader loader,
UnmarshalledReferences refMap, boolean overrideContextClassloaderOnThread) throws
Exception
{
if (loader == null)
{
@@ -530,12 +530,12 @@
try
{
// only do this if we haven't already set a context class loader
elsewhere.
- if (old == null) currentThread.setContextClassLoader(loader);
+ if (overrideContextClassloaderOnThread || old == null)
currentThread.setContextClassLoader(loader);
return unmarshallObject(in, refMap);
}
finally
{
- if (old == null) currentThread.setContextClassLoader(null);
+ if (overrideContextClassloaderOnThread || old == null)
currentThread.setContextClassLoader(null);
}
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java 2008-02-07
15:45:29 UTC (rev 5324)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java 2008-02-07
17:47:59 UTC (rev 5325)
@@ -52,12 +52,7 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- if (cache != null)
- {
- cache.stop();
- cache = null;
- rman = null;
- }
+ TestingUtil.killCaches(cache);
}
public void testDefaultActive() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/AsyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/AsyncReplTest.java 2008-02-07
15:45:29 UTC (rev 5324)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/AsyncReplTest.java 2008-02-07
17:47:59 UTC (rev 5325)
@@ -52,6 +52,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
+ resetContextClassLoader();
log("creating cache1");
cache1 = createCache("TestCache");
Show replies by date