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 2026/06/29 11:51:00 UTC

[jira] [Commented] (LANG-1828) StringUtils.rightPad() throws OutOfMemoryError when size is Integer.MIN_VALUE

    [ https://issues.apache.org/jira/browse/LANG-1828?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18092297#comment-18092297 ] 

Gary D. Gregory commented on LANG-1828:
---------------------------------------

Hello [~weijunliu] 

You didn't specify what version you are using.

Feel free to provide a PR in GitHub.

> StringUtils.rightPad() throws OutOfMemoryError when size is Integer.MIN_VALUE
> -----------------------------------------------------------------------------
>
>                 Key: LANG-1828
>                 URL: https://issues.apache.org/jira/browse/LANG-1828
>             Project: Commons Lang
>          Issue Type: Bug
>          Components: lang.*
>    Affects Versions: Discussion
>            Reporter: Weijun Liu
>            Priority: Major
>
> StringUtils.rightPad(String str, int size, String padStr) throws OutOfMemoryError instead of returning the original string when size is Integer.MIN_VALUE.
>   Per the API contract, a negative size should return the original string:
>   ▎ StringUtils.rightPad("bat", -1, "yz") = "bat"
>   However, Integer.MIN_VALUE (-2147483648) is a negative value that violates this contract due to an integer overflow.



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