axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "R J Scheuerle Jr" <>
Subject Re: small patch for a more thorough boolean test
Date Tue, 05 Feb 2002 19:54:16 GMT
Thanks for the input Nelson.

You are right.  The code in Axis does not have this bug, but I noticed that
the deserializer code
is extremely lame.  Here is a snippet from

    public Object makeValue(String source) throws Exception
        // If the javaType is a boolean, except a number of different
        if (javaType == boolean.class ||
            Boolean.class.isAssignableFrom(javaType)) {
            // This is a pretty lame test, but it is what the previous code
            switch (source.charAt(0)) {
                case '0': case 'f': case 'F':
                   return Boolean.FALSE;

                case '1': case 't': case 'T':
                   return Boolean.TRUE;

                   throw new NumberFormatException(


So it would be happy for:

deserialize("<result xsi:type=\"xsd:boolean\">foofoo</result>",
+                    new Boolean(false));

Any suggestions?  I would hate to make the code slower by adding
complicated casing checks.


Rich Scheuerle
XML & Web Services Development
512-838-5115  (IBM TL 678-5115)

                      Nelson Minar                                                       
                      <nelson@monkey.or        To:      
                      g>                       cc:                                    
                                               Subject:  small patch for a more thorough boolean
                      02/05/2002 01:46                                                   
                      Please respond to                                                  

There's a bug in Apache SOAP where it doesn't deserialize "1" as
"true". I wrote a test for Axis for the same bug and am including it
here. It's a patch against the latest nightly build.

I was surprised to find this bug doesn't exist in Axis. I thought
Axis, like Apache SOAP, relied on Boolean(String) to parse the XML
data - that doesn't work because Java doesn't parse "1" as true. But
the test passes, so the bug must not be there :-)

.       .      .     .    .   .  . .

diff -Naur xml-axis/java/test/encoding/
--- xml-axis/java/test/encoding/         Tue Feb  5 12:03:01
+++ xml-axis-nelson/java/test/encoding/        Tue Feb  5
19:36:48 2002
@@ -122,7 +122,13 @@

     public void testBoolean() throws Exception {
+        deserialize("<result xsi:type=\"xsd:boolean\">false</result>",
+                    new Boolean(false));
         deserialize("<result xsi:type=\"xsd:boolean\">true</result>",
+                    new Boolean(true));
+        deserialize("<result xsi:type=\"xsd:boolean\">0</result>",
+                    new Boolean(false));
+        deserialize("<result xsi:type=\"xsd:boolean\">1</result>",
                     new Boolean(true));

View raw message