RFR: 8224267: JOptionPane message string with 5000+ newlines produces StackOverflowError [v3]
Alexey Ivanov
aivanov at openjdk.org
Mon Jul 11 12:44:47 UTC 2022
On Mon, 11 Jul 2022 12:29:43 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
> > Hm… there could be problem: **the counter isn't reset** when the function is called again. It's reset only when the limit is reached. Or do I miss another case where the counter is reset?
> >
> > The easiest way could be to introduce a helper function which is called from the main function that breaks the message and to which the recursion counter is passed as a parameter.
>
> I dont think it's a problem with other cases as in those "msg" is non String and so wont recurse as much as successive newline case in this condition, so I have made it to reset in this.
If the message contains new lines, let's say 20 new lines each. Then I call `JOptionPane.showMessageDialog` continuously with the same message. Since the counter is not reset between the calls, the 10th call would stop breaking the message at the first new line in the message, which doesn't look correct.
I think we have just introduced a new bug which needs resolving.
As another thought, shall we indicate the original message is truncated? Add `...` (ellipsis) to the previous line of text?
-------------
PR: https://git.openjdk.org/jdk/pull/9388
More information about the client-libs-dev
mailing list