You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by pi...@apache.org on 2004/11/01 16:01:03 UTC
svn commit: rev 56238 - cocoon/whiteboard/kernel/src/org/apache/cocoon/kernel/runtime
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 {@link 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 {@link 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 {@link 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 @@
* {@link 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");