You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Andrey Utkin (Created) (JIRA)" <ji...@apache.org> on 2012/01/31 08:07:10 UTC

[jira] [Created] (CAMEL-4959) Incorrect caching type converter misses for NaN

Incorrect caching type converter misses for NaN
-----------------------------------------------

                 Key: CAMEL-4959
                 URL: https://issues.apache.org/jira/browse/CAMEL-4959
             Project: Camel
          Issue Type: Bug
          Components: camel-core
    Affects Versions: 2.8.3
            Reporter: Andrey Utkin


When converting Double or Float with value NaN, org.apache.camel.converter.ObjectConverter returns "null". But org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(Class, Exchange, Object) interpret this "null" as "suitable conversion not found" and cache misses. This lead to completely forgetting of conversion for given types.
For example, when conversing Double to Long, all works until Double is NaN. After that, conversion for "Double-to-Long" marked as misses. And  camel stop do any conversion for Double-to-Long until restart.

Possible solution is to modify ObjectConverter`s methods to return "Void.TYPE" instead of "null" for NaN.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CAMEL-4959) Incorrect caching type converter misses for NaN

Posted by "Babak Vahdat (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-4959?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13218079#comment-13218079 ] 

Babak Vahdat commented on CAMEL-4959:
-------------------------------------

Yeah dealing with NaN's directly in BaseTypeConverterRegistry itself was what I was looking for, Thanks!
                
> Incorrect caching type converter misses for NaN
> -----------------------------------------------
>
>                 Key: CAMEL-4959
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4959
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.8.3
>            Reporter: Andrey Utkin
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.8.5, 2.9.1, 2.10.0
>
>
> When converting Double or Float with value NaN, org.apache.camel.converter.ObjectConverter returns "null". But org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(Class, Exchange, Object) interpret this "null" as "suitable conversion not found" and cache misses. This lead to completely forgetting of conversion for given types.
> For example, when conversing Double to Long, all works until Double is NaN. After that, conversion for "Double-to-Long" marked as misses. And  camel stop do any conversion for Double-to-Long until restart.
> Possible solution is to modify ObjectConverter`s methods to return "Void.TYPE" instead of "null" for NaN.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (CAMEL-4959) Incorrect caching type converter misses for NaN

Posted by "Claus Ibsen (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-4959?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen resolved CAMEL-4959.
--------------------------------

    Resolution: Fixed
    
> Incorrect caching type converter misses for NaN
> -----------------------------------------------
>
>                 Key: CAMEL-4959
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4959
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.8.3
>            Reporter: Andrey Utkin
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.8.5, 2.9.1, 2.10.0
>
>
> When converting Double or Float with value NaN, org.apache.camel.converter.ObjectConverter returns "null". But org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(Class, Exchange, Object) interpret this "null" as "suitable conversion not found" and cache misses. This lead to completely forgetting of conversion for given types.
> For example, when conversing Double to Long, all works until Double is NaN. After that, conversion for "Double-to-Long" marked as misses. And  camel stop do any conversion for Double-to-Long until restart.
> Possible solution is to modify ObjectConverter`s methods to return "Void.TYPE" instead of "null" for NaN.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (CAMEL-4959) Incorrect caching type converter misses for NaN

Posted by "Claus Ibsen (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-4959?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen updated CAMEL-4959:
-------------------------------

                Priority: Minor  (was: Major)
           Fix Version/s: 2.10.0
                          2.9.1
                          2.8.5
    Estimated Complexity: Novice  (was: Unknown)
    
> Incorrect caching type converter misses for NaN
> -----------------------------------------------
>
>                 Key: CAMEL-4959
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4959
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.8.3
>            Reporter: Andrey Utkin
>            Priority: Minor
>             Fix For: 2.8.5, 2.9.1, 2.10.0
>
>
> When converting Double or Float with value NaN, org.apache.camel.converter.ObjectConverter returns "null". But org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(Class, Exchange, Object) interpret this "null" as "suitable conversion not found" and cache misses. This lead to completely forgetting of conversion for given types.
> For example, when conversing Double to Long, all works until Double is NaN. After that, conversion for "Double-to-Long" marked as misses. And  camel stop do any conversion for Double-to-Long until restart.
> Possible solution is to modify ObjectConverter`s methods to return "Void.TYPE" instead of "null" for NaN.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CAMEL-4959) Incorrect caching type converter misses for NaN

Posted by "Babak Vahdat (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-4959?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13216731#comment-13216731 ] 

Babak Vahdat commented on CAMEL-4959:
-------------------------------------

I did "Refactor to Method" for the case if the to be converted value is NaN:

http://svn.apache.org/viewvc?view=revision&revision=1293828
                
> Incorrect caching type converter misses for NaN
> -----------------------------------------------
>
>                 Key: CAMEL-4959
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4959
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.8.3
>            Reporter: Andrey Utkin
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.8.5, 2.9.1, 2.10.0
>
>
> When converting Double or Float with value NaN, org.apache.camel.converter.ObjectConverter returns "null". But org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(Class, Exchange, Object) interpret this "null" as "suitable conversion not found" and cache misses. This lead to completely forgetting of conversion for given types.
> For example, when conversing Double to Long, all works until Double is NaN. After that, conversion for "Double-to-Long" marked as misses. And  camel stop do any conversion for Double-to-Long until restart.
> Possible solution is to modify ObjectConverter`s methods to return "Void.TYPE" instead of "null" for NaN.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CAMEL-4959) Incorrect caching type converter misses for NaN

Posted by "Claus Ibsen (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-4959?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13218078#comment-13218078 ] 

Claus Ibsen commented on CAMEL-4959:
------------------------------------

Yeah I have corrected the coverters to deal with NaN.

And yes we need to lookup fast in type converter registry as its used a lot in Camel, and it should be as fast as possible, as it can become a bottleneck.
                
> Incorrect caching type converter misses for NaN
> -----------------------------------------------
>
>                 Key: CAMEL-4959
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4959
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.8.3
>            Reporter: Andrey Utkin
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.8.5, 2.9.1, 2.10.0
>
>
> When converting Double or Float with value NaN, org.apache.camel.converter.ObjectConverter returns "null". But org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(Class, Exchange, Object) interpret this "null" as "suitable conversion not found" and cache misses. This lead to completely forgetting of conversion for given types.
> For example, when conversing Double to Long, all works until Double is NaN. After that, conversion for "Double-to-Long" marked as misses. And  camel stop do any conversion for Double-to-Long until restart.
> Possible solution is to modify ObjectConverter`s methods to return "Void.TYPE" instead of "null" for NaN.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CAMEL-4959) Incorrect caching type converter misses for NaN

Posted by "Babak Vahdat (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-4959?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13217530#comment-13217530 ] 

Babak Vahdat commented on CAMEL-4959:
-------------------------------------

IMHO the changes introduced by of this ticket causes regression failure. To avoid null values being misinterpreted as cache misses we do now convert e.g.

Float.NaN => (Byte) 0

which was not the case before.

Why not just simply *not* mark the conversion as miss *if* the conversion result is (Float.NaN / Double.NaN  ==> null). That's do *not* add any entry for such conversion results into the misses cache and revert back ObjectConverter to what it was before. Does this make sense to you?

And I simply don't get why the misses cache is a ConcurrentMap:

{code} 
protected final ConcurrentMap<TypeMapping, TypeMapping> misses = new ConcurrentHashMap<TypeMapping, TypeMapping>();
{code} 

To my understanding

{code} 
protected final List<TypeMapping> misses = new CopyOnWriteArrayList<TypeMapping>();
{code} 

would be just fine! Why do we need a Map to memorize the cache misses? Where we then do things like

{code} 
misses.put(key, key);
{code}

On it which is not really intuitive while reading the code, is this maybe because ideally we want to do lookup by the misses cache (misses.containsKey()) in O(1) instead of O(N)? 

See also:

http://camel.465427.n5.nabble.com/ObjectConverter-problem-td5517376.html
                
> Incorrect caching type converter misses for NaN
> -----------------------------------------------
>
>                 Key: CAMEL-4959
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4959
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.8.3
>            Reporter: Andrey Utkin
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.8.5, 2.9.1, 2.10.0
>
>
> When converting Double or Float with value NaN, org.apache.camel.converter.ObjectConverter returns "null". But org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(Class, Exchange, Object) interpret this "null" as "suitable conversion not found" and cache misses. This lead to completely forgetting of conversion for given types.
> For example, when conversing Double to Long, all works until Double is NaN. After that, conversion for "Double-to-Long" marked as misses. And  camel stop do any conversion for Double-to-Long until restart.
> Possible solution is to modify ObjectConverter`s methods to return "Void.TYPE" instead of "null" for NaN.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Assigned] (CAMEL-4959) Incorrect caching type converter misses for NaN

Posted by "Claus Ibsen (Assigned) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CAMEL-4959?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen reassigned CAMEL-4959:
----------------------------------

    Assignee: Claus Ibsen
    
> Incorrect caching type converter misses for NaN
> -----------------------------------------------
>
>                 Key: CAMEL-4959
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4959
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.8.3
>            Reporter: Andrey Utkin
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 2.8.5, 2.9.1, 2.10.0
>
>
> When converting Double or Float with value NaN, org.apache.camel.converter.ObjectConverter returns "null". But org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(Class, Exchange, Object) interpret this "null" as "suitable conversion not found" and cache misses. This lead to completely forgetting of conversion for given types.
> For example, when conversing Double to Long, all works until Double is NaN. After that, conversion for "Double-to-Long" marked as misses. And  camel stop do any conversion for Double-to-Long until restart.
> Possible solution is to modify ObjectConverter`s methods to return "Void.TYPE" instead of "null" for NaN.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CAMEL-4959) Incorrect caching type converter misses for NaN

Posted by "Claus Ibsen (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-4959?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13198647#comment-13198647 ] 

Claus Ibsen commented on CAMEL-4959:
------------------------------------

Yeah lets return 0 for the primitive types.

Patches is welcome, with unit tests.
                
> Incorrect caching type converter misses for NaN
> -----------------------------------------------
>
>                 Key: CAMEL-4959
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4959
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.8.3
>            Reporter: Andrey Utkin
>            Priority: Minor
>             Fix For: 2.8.5, 2.9.1, 2.10.0
>
>
> When converting Double or Float with value NaN, org.apache.camel.converter.ObjectConverter returns "null". But org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(Class, Exchange, Object) interpret this "null" as "suitable conversion not found" and cache misses. This lead to completely forgetting of conversion for given types.
> For example, when conversing Double to Long, all works until Double is NaN. After that, conversion for "Double-to-Long" marked as misses. And  camel stop do any conversion for Double-to-Long until restart.
> Possible solution is to modify ObjectConverter`s methods to return "Void.TYPE" instead of "null" for NaN.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CAMEL-4959) Incorrect caching type converter misses for NaN

Posted by "Claus Ibsen (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-4959?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13196780#comment-13196780 ] 

Claus Ibsen commented on CAMEL-4959:
------------------------------------

That is correct. Andrey can you provide a patch with unit test that test this fix?
                
> Incorrect caching type converter misses for NaN
> -----------------------------------------------
>
>                 Key: CAMEL-4959
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4959
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.8.3
>            Reporter: Andrey Utkin
>             Fix For: 2.8.5, 2.9.1, 2.10.0
>
>
> When converting Double or Float with value NaN, org.apache.camel.converter.ObjectConverter returns "null". But org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(Class, Exchange, Object) interpret this "null" as "suitable conversion not found" and cache misses. This lead to completely forgetting of conversion for given types.
> For example, when conversing Double to Long, all works until Double is NaN. After that, conversion for "Double-to-Long" marked as misses. And  camel stop do any conversion for Double-to-Long until restart.
> Possible solution is to modify ObjectConverter`s methods to return "Void.TYPE" instead of "null" for NaN.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (CAMEL-4959) Incorrect caching type converter misses for NaN

Posted by "Andrey Utkin (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CAMEL-4959?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13196819#comment-13196819 ] 

Andrey Utkin commented on CAMEL-4959:
-------------------------------------

Hi, Claus. 
Yes, I can try to make patch with unit test for ObjectConverter.

But suggested solution - return Void.TYPE from toXXXX() methods of ObjectConverter - is not correct :) ObjectConverter is converter, so that methods must declare return type correctly - Short, Long, Integer. It is not possible to return Void from toXXXX()...

May be it is correct to return 0 for NaN? 
At least JDK do it:
==
Double d = Double.NaN;
Float f = Float.NaN;
System.out.println(d.longValue() + ", " + f.shortValue());
==
will print 
"0, 0"


                
> Incorrect caching type converter misses for NaN
> -----------------------------------------------
>
>                 Key: CAMEL-4959
>                 URL: https://issues.apache.org/jira/browse/CAMEL-4959
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.8.3
>            Reporter: Andrey Utkin
>            Priority: Minor
>             Fix For: 2.8.5, 2.9.1, 2.10.0
>
>
> When converting Double or Float with value NaN, org.apache.camel.converter.ObjectConverter returns "null". But org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(Class, Exchange, Object) interpret this "null" as "suitable conversion not found" and cache misses. This lead to completely forgetting of conversion for given types.
> For example, when conversing Double to Long, all works until Double is NaN. After that, conversion for "Double-to-Long" marked as misses. And  camel stop do any conversion for Double-to-Long until restart.
> Possible solution is to modify ObjectConverter`s methods to return "Void.TYPE" instead of "null" for NaN.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira