axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Amila Chinthaka Suriarachchi (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (AXIS2-3287) ConverterUtil.convertToArray fails for boolean.class
Date Fri, 19 Oct 2007 08:09:50 GMT

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

Amila Chinthaka Suriarachchi resolved AXIS2-3287.
-------------------------------------------------

    Resolution: Fixed
      Assignee: Amila Chinthaka Suriarachchi

fixed the issue revision 586305

> 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
>            Assignee: Amila Chinthaka Suriarachchi
>            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