[jira] Created: (CAMEL-270) Error in org.apache.camel.util.ObjectHelper

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (CAMEL-270) Error in org.apache.camel.util.ObjectHelper

JIRA jira@apache.org
Error in org.apache.camel.util.ObjectHelper
-------------------------------------------

                 Key: CAMEL-270
                 URL: https://issues.apache.org/activemq/browse/CAMEL-270
             Project: Apache Camel
          Issue Type: Bug
          Components: camel-core
    Affects Versions: 1.3.0
            Reporter: Axel Hohaus


Found an error in method contains of class org.apache.camel.util.ObjectHelper.
If using an array instead of a collection.

Following line is wrong:
Iterator iter = ObjectConverter.iterator(value);

It should be iterated over collectionOrArray variable.
Correct line is:
Iterator iter = ObjectConverter.iterator(collectionOrArray);


Complete new method is:

public static boolean contains(Object collectionOrArray, Object value) {
    if (collectionOrArray instanceof Collection) {
        Collection collection = (Collection)collectionOrArray;
        return collection.contains(value);
    } else {
        Iterator iter = ObjectConverter.iterator(value);
        while (iter.hasNext()) {
            if (equal(value, iter.next())) {
                return true;
            }
        }
        return false;
    }
}


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

Reply | Threaded
Open this post in threaded view
|

[jira] Resolved: (CAMEL-270) Error in org.apache.camel.util.ObjectHelper

JIRA jira@apache.org

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

Willem Jiang resolved CAMEL-270.
--------------------------------

       Resolution: Fixed
    Fix Version/s: 1.3.0

> Error in org.apache.camel.util.ObjectHelper
> -------------------------------------------
>
>                 Key: CAMEL-270
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-270
>             Project: Apache Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 1.3.0
>            Reporter: Axel Hohaus
>             Fix For: 1.3.0
>
>
> Found an error in method contains of class org.apache.camel.util.ObjectHelper.
> If using an array instead of a collection.
> Following line is wrong:
> Iterator iter = ObjectConverter.iterator(value);
> It should be iterated over collectionOrArray variable.
> Correct line is:
> Iterator iter = ObjectConverter.iterator(collectionOrArray);
> Complete new method is:
> public static boolean contains(Object collectionOrArray, Object value) {
>     if (collectionOrArray instanceof Collection) {
>         Collection collection = (Collection)collectionOrArray;
>         return collection.contains(value);
>     } else {
>         Iterator iter = ObjectConverter.iterator(value);
>         while (iter.hasNext()) {
>             if (equal(value, iter.next())) {
>                 return true;
>             }
>         }
>         return false;
>     }
> }

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