Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#218 NullPointerException during startup

open
Amir Shevat
General (90)
5
2006-07-26
2006-07-26
Anonymous
No

affected version:
MantaRay 2.0

bug description:
NullPointerException thrown during startup.

2006-07-26 14:57:51,073 FATAL
WorldModelerLoader[Thread-2] - can not load world modeler
java.lang.NullPointerException
at
org.mr.core.configuration.ConfigurationElement.getSubConfigurationElementByName(ConfigurationElement.java:195)
at
org.mr.kernel.world.WorldModelerLoader.load(WorldModelerLoader.java:184)
at org.mr.MantaAgent.init(MantaAgent.java:278)
at
org.mr.api.jms.MantaConnectionFactory.getChannel(MantaConnectionFactory.java:216)
at
org.mr.api.jms.MantaConnection.<init>(MantaConnection.java:147)
at
org.mr.api.jms.MantaTopicConnection.<init>(MantaTopicConnection.java:99)
at
org.mr.api.jms.MantaTopicConnectionFactory.createTopicConnection(MantaTopicConnectionFactory.java:107)
at
org.mr.api.jms.MantaTopicConnectionFactory.createTopicConnection(MantaTopicConnectionFactory.java:97)
... and some more

cause:
In class org.mr.core.configuration.ConfigurationElement
the subConfigurationElementsMap is not initialized if
it is a leaf.
Later in public ConfigurationElement
getSubConfigurationElementByName(String subName),
subConfigurationElementsMap is accessed
without prior check if it is null.

possible solution:
Check if subConfigurationElementsMap is null before
accessing it.

original code:
public ConfigurationElement
getSubConfigurationElementByName(String subName) {
ConfigurationElement result = null;
ArrayList sub = (ArrayList)
subConfigurationElementsMap.get(subName);
if(sub!=null){
result = (ConfigurationElement) sub.get(0);
}
return result;
}

changed code:
public ConfigurationElement
getSubConfigurationElementByName(String subName) {
ConfigurationElement result = null;
if(subConfigurationElementsMap!=null)
{
ArrayList sub = (ArrayList)
subConfigurationElementsMap.get(subName);
if(sub!=null){
result = (ConfigurationElement) sub.get(0);
}
}
return result;
}

submitters:
frank.thomas[at]systemagmbh.de
christian.wohanka[at]systemagmbh.de

sorry for submitting bug 1528966 twice (duplicate 1528974)

thanks for looking into this

Discussion