Skip to content

Commit bab1f6c

Browse files
committed
[COLLECTIONS-874] MapUtils.getLongValue(Map, K, Function) returns a byte
instead of a long
1 parent a4c4964 commit bab1f6c

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<action type="fix" dev="ggregory" due-to="Eric Hubert, Gary Gregory">Remove deprecation annotation of org.apache.commons.collections4.Predicate; this will be deprecated in 5.0 in favor of java.util.function.Predicate.</action>
3030
<action type="fix" dev="ggregory" due-to="Eric Hubert, Gary Gregory">Remove deprecation annotation of org.apache.commons.collections4.Transformer; this will be deprecated in 5.0 in favor of java.util.function.Function.</action>
3131
<action type="fix" dev="ggregory" due-to="Eric Hubert, Gary Gregory">Remove deprecation annotation of org.apache.commons.collections4.Closure; this will be deprecated in 5.0 in favor of java.util.function.Consumer.</action>
32+
<action type="fix" dev="ggregory" due-to="Sebastian Götz, Gary Gregory" issue="COLLECTIONS-874">MapUtils.getLongValue(Map, K, Function) returns a byte instead of a long.</action>
3233
<!-- ADD -->
3334
<!-- UPDATE -->
3435
<action type="update" dev="ggregory" due-to="Gary Gregory, Dependabot">Bump org.apache.commons:commons-parent from 81 to 83 #612.</action>

src/main/java/org/apache/commons/collections4/MapUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ public static <K> long getLongValue(final Map<? super K, ?> map, final K key) {
838838
*/
839839
public static <K> long getLongValue(final Map<? super K, ?> map, final K key,
840840
final Function<K, Long> defaultFunction) {
841-
return applyDefaultFunction(map, key, MapUtils::getLong, defaultFunction, 0L).byteValue();
841+
return applyDefaultFunction(map, key, MapUtils::getLong, defaultFunction, 0L).longValue();
842842
}
843843

844844
/**

src/test/java/org/apache/commons/collections4/MapUtilsTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,8 @@ public void testGetLongValue() {
499499
assertEquals(2.0, MapUtils.getLongValue(in, "key"), 0);
500500
assertEquals(1, MapUtils.getLongValue(in, "noKey", 1L), 0);
501501
assertEquals(1, MapUtils.getLongValue(in, "noKey", key -> 1L), 0);
502+
assertEquals(Long.MIN_VALUE, MapUtils.getLongValue(in, "noKey", key -> Long.MIN_VALUE), 0);
503+
assertEquals(Long.MAX_VALUE, MapUtils.getLongValue(in, "noKey", key -> Long.MAX_VALUE), 0);
502504
assertEquals(0, MapUtils.getLongValue(in, "noKey"), 0);
503505
assertEquals(2.0, MapUtils.getLong(in, "key", 0L), 0);
504506
assertEquals(1, MapUtils.getLong(in, "noKey", 1L), 0);

0 commit comments

Comments
 (0)