Author: pier Date: Mon Nov 1 07:01:03 2004 New Revision: 56238 Modified: cocoon/whiteboard/kernel/src/org/apache/cocoon/kernel/runtime/Runtime.java Log: Avoid illegal access and null pointer exceptions
Modified: cocoon/whiteboard/kernel/src/org/apache/cocoon/kernel/runtime/Runtime.java ============================================================================== --- cocoon/whiteboard/kernel/src/org/apache/cocoon/kernel/runtime/Runtime.java (original) +++ cocoon/whiteboard/kernel/src/org/apache/cocoon/kernel/runtime/Runtime.java Mon Nov 1 07:01:03 2004 @@ -61,6 +61,8 @@ */ protected void add(String name, Instance instance, Configuration configuration) { if (name == null) throw new NullPointerException("Null name"); + if (instance == null) throw new NullPointerException("Null instance"); + if (configuration == null) throw new NullPointerException("Null config"); this.wrappers.put(name, new Wrapper(instance, configuration)); } @@ -75,21 +77,24 @@ * <p>Return the [EMAIL PROTECTED] Block} associated with the given name.</p> */ public Block getBlock(String name) { - return ((Wrapper)this.wrappers.get(name)).instance.getBlock(); + Wrapper wrapper = (Wrapper) this.wrappers.get(name); + return (wrapper == null? null : wrapper.instance.getBlock()); } /** * <p>Return the [EMAIL PROTECTED] Instance} associated with the given name.</p> */ public Instance getInstance(String name) { - return ((Wrapper)this.wrappers.get(name)).instance; + Wrapper wrapper = (Wrapper) this.wrappers.get(name); + return (wrapper == null? null : wrapper.instance); } /** * <p>Return the [EMAIL PROTECTED] Configuration} associated with the given name.</p> */ public Configuration getConfiguration(String name) { - return ((Wrapper)this.wrappers.get(name)).configuration; + Wrapper wrapper = (Wrapper) this.wrappers.get(name); + return (wrapper == null? null : wrapper.configuration); } /** @@ -97,8 +102,8 @@ * [EMAIL PROTECTED] Configuration}s.</p> */ private static final class Wrapper { - private Instance instance = null; - private Configuration configuration = null; + protected Instance instance = null; + protected Configuration configuration = null; private Wrapper(Instance instance, Configuration config) { if (instance == null) throw new NullPointerException("Null instance"); if (config == null) throw new NullPointerException("Null configuration");