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

Gary D. Gregory resolved COLLECTIONS-874.
-----------------------------------------
    Fix Version/s: 4.5.1
         Assignee: Gary D. Gregory
       Resolution: Fixed

Hi [~s.goetz] and good catch.

This is now fixed in git master and our Maven snapshot repository: 
[https://repository.apache.org/content/repositories/snapshots/]

 

> MapUtils.getLongValue(Map<? super K, ?>, K, Function<K, Long>) returns a byte 
> instead of a long
> -----------------------------------------------------------------------------------------------
>
>                 Key: COLLECTIONS-874
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-874
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: Map
>    Affects Versions: 4.5.0
>            Reporter: Sebastian Götz
>            Assignee: Gary D. Gregory
>            Priority: Major
>             Fix For: 4.5.1
>
>
> When using the following method
> {code:java}
> org.apache.commons.collections4.MapUtils.getLongValue(Map<? super K, ?>, K, 
> Function<K, Long>)
> {code}
> the resulting value no matter if it is the value returned by the 
> defaultFunction or the value contained in the map is returned as byte:
> {code:java}
> return applyDefaultFunction(map, key, MapUtils::getLong, defaultFunction, 
> 0L).byteValue();
> {code}
> The problem ist the final call to {{{}byteValue(){}}}. If the returned value 
> is greater than 127 the implicit cast back to a long will make it a negative 
> number (e.g. the byte 0xaf/175 will become 0xffffffffffffffaf/-81). 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to