RFR: 8291792: DefaultStyledDocument.setCharacterAttribute accepts negative length [v5]

Phil Race prr at openjdk.org
Fri Aug 26 18:52:02 UTC 2022


On Thu, 25 Aug 2022 03:27:49 GMT, Tejesh R <tr at openjdk.org> wrote:

>> The Document for _DefaultStyledDocument.setCharacterAttribute_ states that the range of length accepted is `length - the length >= 0`, whereas in code the length check is done only for `length==0`. Meaning the control just returns if the `length` is 0. Since length is  _int_ type and there is a possibility of negative length being set through the method, the code doesn't actually handles the negative length case. Hence to handle negative length, negative length check has been added along with 0 check. Its safe to check and return the control for `negative` length input. Test case to check the same is added.
>
> Tejesh R has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Updated based on review comments

OK but you need to change the title of this PR to match JBS.

-------------

Marked as reviewed by prr (Reviewer).

PR: https://git.openjdk.org/jdk/pull/9830



More information about the client-libs-dev mailing list