You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2025/05/20 11:30:00 UTC

[jira] [Updated] (COLLECTIONS-874) MapUtils.getLongValue(Map, K, Function) actually returns a byte

     [ 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>) actually returns a byte  (was: Maputils.getLongValue actually returns a byte)

> MapUtils.getLongValue(Map<? super K, ?>, K, Function<K, Long>) actually returns a byte
> --------------------------------------------------------------------------------------
>
>                 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)