RFR: 8180276: JTextPane getText return extra when mixed with methods of Document [v2]

Prasanta Sadhukhan psadhukhan at openjdk.java.net
Mon Apr 11 04:54:37 UTC 2022


On Fri, 8 Apr 2022 12:06:06 GMT, Tejesh R <duke at openjdk.java.net> wrote:

> Yes, the original issue was observed and raised in Windows alone...... In Mac and Linux the control wont even enters this logic -
> 
> ```
>   if (endOfLineProperty != null && !endOfLine.equals("\n")) {
>             // There is an end of line string that isn't \n, have to iterate
>             // through and find all \n's and translate to end of line string.
> ```

Since you mentioned in mac/linux it wont even enter the above path, then I guess in below code

if (array[counter - 1] == '\r') {
                                out.write(array, last, counter - last - 1);
                            } else {
                                out.write(array, last, counter - last);
                            }

the else part is a no-op as in windows \r\n is present so I think always the check `if (array[counter - 1] == '\r')` will be satisfied

If this is true, then I guess we can remove `if (array[counter - 1] == '\r')` check too as it is always true in windows..

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

PR: https://git.openjdk.java.net/jdk/pull/8122



More information about the client-libs-dev mailing list