RFR: 8224267: JOptionPane message string with 5000+ newlines produces StackOverflowError [v3]

j3graham duke at openjdk.org
Tue Jul 12 03:24:44 UTC 2022


On Mon, 11 Jul 2022 09:28:22 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

>> BasicOptionPaneUI.addMessageComponents() uses recursion to split message strings at newlines, generating a StackOverflowError when the message string contains an unusually large number of newlines.
>> Fixed by catching StackOverflow and ignoring so that application is not stuck.
>
> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Format

An alternative approach would be to avoid recursion when splitting the string.

Instead, create a new private method that does the string processing for strings without newlines. Then split the string on newlines, and call that new method for each one. “String.lines” might be a close enough match to do the splitting - one difference would be that it always splits on \r, \n and \r\n instead of looking at the system newline value.

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

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



More information about the client-libs-dev mailing list