Author: violetagg
Date: Sat Mar 14 10:59:38 2015
New Revision: 1666649
URL: http://svn.apache.org/r1666649
Log:
Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=57704
Access instanceManager via get/set methods.
Fix potential NPEs. In web app start if a problem occur prior to
instanceManager initialization then:
- SCI.onStart will fail if it tries to use instanceManager
- During web app stop, StandardContext.listenerStop will fail if it tries to
use instanceManager
Modified:
tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java
tomcat/trunk/java/org/apache/catalina/core/StandardContext.java
Modified: tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java?rev=1666649&r1=1666648&r2=1666649&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java
(original)
+++ tomcat/trunk/java/org/apache/catalina/core/ApplicationContext.java Sat Mar
14 10:59:38 2015
@@ -1248,16 +1248,18 @@ public class ApplicationContext
public void addListener(String className) {
try {
- Object obj = context.getInstanceManager().newInstance(className);
+ if (context.getInstanceManager() != null) {
+ Object obj =
context.getInstanceManager().newInstance(className);
- if (!(obj instanceof EventListener)) {
- throw new IllegalArgumentException(sm.getString(
- "applicationContext.addListener.iae.wrongType",
- className));
- }
+ if (!(obj instanceof EventListener)) {
+ throw new IllegalArgumentException(sm.getString(
+ "applicationContext.addListener.iae.wrongType",
+ className));
+ }
- EventListener listener = (EventListener) obj;
- addListener(listener);
+ EventListener listener = (EventListener) obj;
+ addListener(listener);
+ }
} catch (IllegalAccessException e) {
throw new IllegalArgumentException(sm.getString(
"applicationContext.addListener.iae.cnfe", className),
Modified: tomcat/trunk/java/org/apache/catalina/core/StandardContext.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardContext.java?rev=1666649&r1=1666648&r2=1666649&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardContext.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardContext.java Sat Mar 14
10:59:38 2015
@@ -4644,7 +4644,7 @@ public class StandardContext extends Con
listeners[i] + "'");
try {
String listener = listeners[i];
- results[i] = instanceManager.newInstance(listener);
+ results[i] = getInstanceManager().newInstance(listener);
} catch (Throwable t) {
t = ExceptionUtils.unwrapInvocationTargetException(t);
ExceptionUtils.handleThrowable(t);
@@ -4782,7 +4782,9 @@ public class StandardContext extends Con
}
}
try {
- getInstanceManager().destroyInstance(listeners[j]);
+ if (getInstanceManager() != null) {
+ getInstanceManager().destroyInstance(listeners[j]);
+ }
} catch (Throwable t) {
t = ExceptionUtils.unwrapInvocationTargetException(t);
ExceptionUtils.handleThrowable(t);
@@ -4802,7 +4804,9 @@ public class StandardContext extends Con
if (listeners[j] == null)
continue;
try {
- getInstanceManager().destroyInstance(listeners[j]);
+ if (getInstanceManager() != null) {
+ getInstanceManager().destroyInstance(listeners[j]);
+ }
} catch (Throwable t) {
t = ExceptionUtils.unwrapInvocationTargetException(t);
ExceptionUtils.handleThrowable(t);
@@ -5452,7 +5456,7 @@ public class StandardContext extends Con
}
//reset the instance manager
- instanceManager = null;
+ setInstanceManager(null);
if (log.isDebugEnabled())
log.debug("Stopping complete");
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]