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

Gary D. Gregory updated COLLECTIONS-874:
----------------------------------------
    Summary: MapUtils.getLongValue(Map<? super K, ?>, K, Function<K, Long>) 
returns a byte instead of a long  (was: MapUtils.getLongValue(Map<? super K, 
?>, K, Function<K, Long>) actually returns a byte)

> 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
>            Priority: Major
>
> 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