axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thorsten H. Riek (JIRA)" <j...@apache.org>
Subject [jira] Updated: (AXIS2-3287) ConverterUtil.convertToArray fails for boolean.class
Date Thu, 18 Oct 2007 20:31:50 GMT

     [ https://issues.apache.org/jira/browse/AXIS2-3287?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Thorsten H. Riek updated AXIS2-3287:
------------------------------------

    Description: 
Conversion  ConverterUtil.convertToArray  fails for 

   String[] testString = {"true","false"};
   Object[] convertedObj = ConverterUtil.convertToArray( boolean.class, testString );

The Result is:

   convertedObj[0] --> false
   convertedObj[1] --> false

The Problem is the conversion from String to boolean is wrong:

org.apache.axis2.databinding.utils.ConverterUtil.convertToArray
// >>-----------------------------------------------------------------
} else if (boolean.class.equals(baseArrayClass)) {
            boolean[] array = new boolean[listSize];
            for (int i = 0; i < listSize; i++) {
                Object o = objectList.get(i);
                if (o != null) {
                    array[i] = Boolean.getBoolean(o.toString());
                }
            }
            returnArray = array;
}
// <<-----------------------------------------------------------------

   array[i] = Boolean.getBoolean(o.toString()); is wrong

it should be:

   array[i] = Boolean.parseBoolean(o.toString());




Here is the modified Testcase to reproduce it:

ConverterUtilTest

// >>-----------------------------------------------------------------
    /** boolean arrays */
    public void testBool() {
        List l = new ArrayList();
        l.add("true");
        l.add("false");
        l.add("true");
        l.add("false");

        Object convertedObj = ConverterUtil.convertToArray(
                boolean.class, l);

        assertTrue(convertedObj.getClass().isArray());
        assertTrue(convertedObj.getClass().equals(boolean[].class));
        
        if (convertedObj.getClass().isArray()) {
            Object[] result = l.toArray();
            for (int i=0;i<result.length ; i++){
                System.out.println(Boolean.parseBoolean((String) result[i])+" == "+((boolean[])convertedObj)[i]);
                assertTrue(Boolean.parseBoolean((String)result[i])==((boolean[])convertedObj)[i]);
            }
        }

    }
// <<-----------------------------------------------------------------


  was:
Conversion  ConverterUtil.convertToArray  fails for 

String[] testString = {"true","false"};

Object[] convertedObj = ConverterUtil.convertToArray( boolean.class, testString );

The Result is:

convertedObj[0] --> false
convertedObj[1] --> false

The Problem is the conversion from String to boolean is wrong:

org.apache.axis2.databinding.utils.ConverterUtil.convertToArray
{noformat}
} else if (boolean.class.equals(baseArrayClass)) {
            boolean[] array = new boolean[listSize];
            for (int i = 0; i < listSize; i++) {
                Object o = objectList.get(i);
                if (o != null) {
                    array[i] = Boolean.getBoolean(o.toString());
                }
            }
            returnArray = array;
{noformat}

array[i] = Boolean.getBoolean(o.toString()); is wrong

it should be:

array[i] = Boolean.parse(o.toString());

Here is the modified Testcase to reproduce it:

ConverterUtilTest

{noformat}
    /** boolean arrays */
    public void testBool() {
        List l = new ArrayList();
        l.add("true");
        l.add("false");
        l.add("true");
        l.add("false");

        Object convertedObj = ConverterUtil.convertToArray(
                boolean.class, l);

        assertTrue(convertedObj.getClass().isArray());
        assertTrue(convertedObj.getClass().equals(boolean[].class));
        
        if (convertedObj.getClass().isArray()) {
            Object[] result = l.toArray();
            for (int i=0;i<result.length ; i++){
                System.out.println(Boolean.parseBoolean((String) result[i])+" == "+((boolean[])convertedObj)[i]);
                assertTrue(Boolean.parseBoolean((String)result[i])==((boolean[])convertedObj)[i]);
            }
        }

    }

{noformat}


> ConverterUtil.convertToArray fails for boolean.class
> ----------------------------------------------------
>
>                 Key: AXIS2-3287
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3287
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>          Components: adb, databinding
>    Affects Versions: 1.4, 1.3
>         Environment: Maven version: 2.0.7
> Java version: 1.6.0_02
> OS name: "windows xp" version: "5.1" arch: "x86"
>            Reporter: Thorsten H. Riek
>            Priority: Critical
>
> Conversion  ConverterUtil.convertToArray  fails for 
>    String[] testString = {"true","false"};
>    Object[] convertedObj = ConverterUtil.convertToArray( boolean.class, testString );
> The Result is:
>    convertedObj[0] --> false
>    convertedObj[1] --> false
> The Problem is the conversion from String to boolean is wrong:
> org.apache.axis2.databinding.utils.ConverterUtil.convertToArray
> // >>-----------------------------------------------------------------
> } else if (boolean.class.equals(baseArrayClass)) {
>             boolean[] array = new boolean[listSize];
>             for (int i = 0; i < listSize; i++) {
>                 Object o = objectList.get(i);
>                 if (o != null) {
>                     array[i] = Boolean.getBoolean(o.toString());
>                 }
>             }
>             returnArray = array;
> }
> // <<-----------------------------------------------------------------
>    array[i] = Boolean.getBoolean(o.toString()); is wrong
> it should be:
>    array[i] = Boolean.parseBoolean(o.toString());
> Here is the modified Testcase to reproduce it:
> ConverterUtilTest
> // >>-----------------------------------------------------------------
>     /** boolean arrays */
>     public void testBool() {
>         List l = new ArrayList();
>         l.add("true");
>         l.add("false");
>         l.add("true");
>         l.add("false");
>         Object convertedObj = ConverterUtil.convertToArray(
>                 boolean.class, l);
>         assertTrue(convertedObj.getClass().isArray());
>         assertTrue(convertedObj.getClass().equals(boolean[].class));
>         
>         if (convertedObj.getClass().isArray()) {
>             Object[] result = l.toArray();
>             for (int i=0;i<result.length ; i++){
>                 System.out.println(Boolean.parseBoolean((String) result[i])+" == "+((boolean[])convertedObj)[i]);
>                 assertTrue(Boolean.parseBoolean((String)result[i])==((boolean[])convertedObj)[i]);
>             }
>         }
>     }
> // <<-----------------------------------------------------------------

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Mime
View raw message