Menu

#109 Null Pointer Exception

open
Steve
API (125)
5
2012-12-15
2010-11-04
No

In com.vmware.vim25.ws.XmlGenAn exception is being caught, then null returned. The calling code is not checking for null and continues, causing an NPE. Believe the solution should be to rethrow the error, because calling code already handles exceptions. Looking elsewhere in the module, there may be other cases of null being returned after catch clauses.

XmlGen::getVimClass

In getVimClass() it tries to
{
String compType = type.substring(0, type.length()-2);
clazz = Array.newInstance(getVimClass(compType), 0).getClass();  This failed and threw an exception
}
VimClasses.put(type, clazz);
return clazz;
} catch (ClassNotFoundException cnfe)
{
cnfe.printStackTrace();
return null;  instead of passing up the exception, it returns null
}

The calling code WsClient.java:

if(xsiType!=null && (!xsiType.startsWith("xsd:")))
{
fRealType = getVimClass(xsiType);  getting a null
}

}
else if(fRealType.isEnum())  bombing on the null
{ // Enum type

Discussion