You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Geir Egil Hansen (JIRA)" <ax...@ws.apache.org> on 2005/11/04 09:26:19 UTC
[jira] Created: (AXIS-2286) Client side does not handle null values for primitive types, causes NullPointerException
Client side does not handle null values for primitive types, causes NullPointerException
----------------------------------------------------------------------------------------
Key: AXIS-2286
URL: http://issues.apache.org/jira/browse/AXIS-2286
Project: Apache Axis
Type: Bug
Components: Serialization/Deserialization
Versions: 1.3
Reporter: Geir Egil Hansen
In Java there are some default values for objects that are not initialized. If you define an "int value;" it is assumed to have a value of 0.
If you define a "boolean value;" it is assumed to get a value of "false" etc.
Let us say I have a class on the server side like:
class MyClass{
String str;
int no;
}
If the client fill in the "str" field but does not set a value of "no" it is depending on the implementing language (client side programming language) on what value "no" will get. If it is a Java client I would assume it to be 0. If it is a C or C++ client though, it is not defined in the standard what value it should get. It is up to the compiler vendor. My problem occurred when a customer used the latest Borland C++ Builder (version 2006). And the same problem seems to occur when calling the WebService using Mindreef SOAPscope version 4.1.12095 (SP2). The "no" does simply not have any value at all. On the server side this comes in as "null" instead of an Integer. One can of course discuss wether this be a bug on the client side or not, but for me the problem is on teh server side.
In the class BeanPropertyTarget at around line 70 something, in the method set, an exception is thrown whe calling "pd.set(object, value);". fair enough. BUT on the next lines it is assumed that the method argument is NOT null:
try {
// If an exception occurred,
// see it the value can be converted into
// the expected type.
Class type = pd.getType();
if (value.getClass().isArray()
&& value.getClass().g......etc
However, in this case the value is null, and will thus cause a NullPointerException at "if (value.getClass().isArray() ...."
Firstly I think that the value object reference must be checked for null value before using.
Second, I think that for primitive types, if the value argument here is null, the Java language default values should be applied. Like 0 for an int, false for a boolean, etc
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira