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 Steve Green <st...@epok.net> on 2005/01/05 17:30:08 UTC

Deserializing Booleans (and maybe other primitives)

Developers,

I did a CVS up yesterday.  It seems that some recent refactoring may 
have broken the way Booleans are deserialized.  This is what I am 
seeing.

I have a SOAP header coming in with mustUnderstand="1".  That "1" is 
finding it's way to new Boolean("1"), which gets evaluated as false.

SimpleDeserializer has makeBasicValue() which looks for "1" (as well as 
"t" and "T"), but makeBasicValue() is never called because 
SimpleDeserializerFactory doesn't consider Boolean as a basic type.

     private static boolean isBasic(Class javaType) {
         return (javaType.isPrimitive() ||
                 javaType == java.lang.String.class ||
                 javaType == org.apache.axis.types.URI.class);
     }

One possible fix would be to reflect the java class, looking for the 
TYPE field, or to simply test for java.lang.Boolean.class, but 
admittedly I don't know this code well enough to propose anything.

makeBasicValue() also has special case code for a bunch of the other 
primitives too.  I am suspecting isBasic() needs to deal with them too, 
or perhaps makeBasicValue() doesn't need those cases anymore.

If someone can chime in on the best way to fix the problem, I'll create 
a report and attach a fix.

~S


RE: Deserializing Booleans (and maybe other primitives)

Posted by Jarek Gawor <ga...@mcs.anl.gov>.
Steve,

This should be fixed now.

Jarek

> -----Original Message-----
> From: Steve Green [mailto:steveg@epok.net] 
> Sent: Wednesday, January 05, 2005 11:30 AM
> To: axis-dev@ws.apache.org
> Subject: Deserializing Booleans (and maybe other primitives)
> 
> 
> Developers,
> 
> I did a CVS up yesterday.  It seems that some recent refactoring may 
> have broken the way Booleans are deserialized.  This is what I am 
> seeing.
> 
> I have a SOAP header coming in with mustUnderstand="1".  That "1" is 
> finding it's way to new Boolean("1"), which gets evaluated as false.
> 
> SimpleDeserializer has makeBasicValue() which looks for "1" 
> (as well as 
> "t" and "T"), but makeBasicValue() is never called because 
> SimpleDeserializerFactory doesn't consider Boolean as a basic type.
> 
>      private static boolean isBasic(Class javaType) {
>          return (javaType.isPrimitive() ||
>                  javaType == java.lang.String.class ||
>                  javaType == org.apache.axis.types.URI.class);
>      }
> 
> One possible fix would be to reflect the java class, looking for the 
> TYPE field, or to simply test for java.lang.Boolean.class, but 
> admittedly I don't know this code well enough to propose anything.
> 
> makeBasicValue() also has special case code for a bunch of the other 
> primitives too.  I am suspecting isBasic() needs to deal with 
> them too, 
> or perhaps makeBasicValue() doesn't need those cases anymore.
> 
> If someone can chime in on the best way to fix the problem, 
> I'll create 
> a report and attach a fix.
> 
> ~S
> 
>