You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "rootvector2 (via GitHub)" <gi...@apache.org> on 2026/07/06 13:02:47 UTC
[PR] fix MapUtils.getIntValue(Map, K, Function) returning a byte [commons-collections]
rootvector2 opened a new pull request, #704:
URL: https://github.com/apache/commons-collections/pull/704
`MapUtils.getIntValue(Map, K, Function)` narrows the resolved `Integer` through `.byteValue()`, so any value outside signed-byte range comes back truncated: a map entry of `1000` returns `-24`, and a `defaultFunction` yielding `Integer.MAX_VALUE` returns `-1`. This is the same defect fixed under COLLECTIONS-874 for the sibling `getLongValue(Map, K, Function)`, which moved to `.longValue()`; the `int` overload kept `.byteValue()`. Found while checking that each `getXxxValue(Map, K, Function)` matches its declared return type.
Use `.intValue()` like every other numeric overload. `testGetIntValue` only drove the `Function` variant with `key -> 0`, which is unaffected by the narrowing, so the gap stayed invisible; the added assertions pin a map value and a default-function value that fall outside byte range.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix MapUtils.getIntValue(Map, K, Function) returning a byte [commons-collections]
Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on PR #704:
URL: https://github.com/apache/commons-collections/pull/704#issuecomment-4895463304
Thank you @rootvector2 , merged 🚀 I appreciate the extra look.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix MapUtils.getIntValue(Map, K, Function) returning a byte [commons-collections]
Posted by Sungchan Park <sc...@gmail.com>.
Unsubscribe
나의 iPhone에서 보냄
> 2026. 7. 6. 오후 11:27, rootvector2 <gi...@apache.org> 작성:
>
>
> rootvector2 commented on PR #704:
> URL: https://github.com/apache/commons-collections/pull/704#issuecomment-4893884140
>
> checked all 18 `getXxxValue` methods against their declared return type. this `getIntValue(Map, K, Function)` narrowing to `.byteValue()` is the only mismatch, everything else (`byte`/`short`/`long`/`float`/`double` function overloads, plus every `defaultValue` overload) narrows to its own type. so no other copy-paste like COLLECTIONS-874 is lurking.
>
> on tests: the `Function` overloads were the blind spot. `getIntValue` was only driven with `key -> 0`, which survives the truncation, so the bug stayed invisible. `getLongValue` already covers `Long.MIN/MAX_VALUE` through the function variant. `getShortValue` had the same weak spot, its function overload was only exercised with `10` (fits in a byte), while the `MIN/MAX` assertions go through the `short` overload instead. pushed a one-liner there driving `key -> (short) 1000` so a future `.byteValue()` slip would be caught. `byte`/`double`/`float` can't narrow past their own source type, so nothing to add there.
>
>
> --
> This is an automated message from the Apache Git Service.
> To respond to the message, please log on to GitHub and use the
> URL above to go to the specific comment.
>
> To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
>
> For queries about this service, please contact Infrastructure at:
> users@infra.apache.org
>
Re: [PR] Fix MapUtils.getIntValue(Map, K, Function) returning a byte [commons-collections]
Posted by "rootvector2 (via GitHub)" <gi...@apache.org>.
rootvector2 commented on PR #704:
URL: https://github.com/apache/commons-collections/pull/704#issuecomment-4893884140
checked all 18 `getXxxValue` methods against their declared return type. this `getIntValue(Map, K, Function)` narrowing to `.byteValue()` is the only mismatch, everything else (`byte`/`short`/`long`/`float`/`double` function overloads, plus every `defaultValue` overload) narrows to its own type. so no other copy-paste like COLLECTIONS-874 is lurking.
on tests: the `Function` overloads were the blind spot. `getIntValue` was only driven with `key -> 0`, which survives the truncation, so the bug stayed invisible. `getLongValue` already covers `Long.MIN/MAX_VALUE` through the function variant. `getShortValue` had the same weak spot, its function overload was only exercised with `10` (fits in a byte), while the `MIN/MAX` assertions go through the `short` overload instead. pushed a one-liner there driving `key -> (short) 1000` so a future `.byteValue()` slip would be caught. `byte`/`double`/`float` can't narrow past their own source type, so nothing to add there.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix MapUtils.getIntValue(Map, K, Function) returning a byte [commons-collections]
Posted by "rootvector2 (via GitHub)" <gi...@apache.org>.
rootvector2 commented on PR #704:
URL: https://github.com/apache/commons-collections/pull/704#issuecomment-4895495126
Thanks❤️
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix MapUtils.getIntValue(Map, K, Function) returning a byte [commons-collections]
Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on PR #704:
URL: https://github.com/apache/commons-collections/pull/704#issuecomment-4893644448
@rootvector2
Thank you for the PR.
Do you see any other issues where there is a conversion mismatch like the one fixed here. It seems like something that happened with some copy-paste. I wonder if we have other missing unit tests for this class. Would you please check?
TY!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix MapUtils.getIntValue(Map, K, Function) returning a byte [commons-collections]
Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory merged PR #704:
URL: https://github.com/apache/commons-collections/pull/704
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org