[8u-dev] Request for Approval: 8160941: [macosx]"text/uri-list" dataflavor concats the first two strings

Robin Stevens stevensro at gmail.com
Fri Jul 15 13:46:04 UTC 2016


this was discussed in the previous review thread as well (
It will indeed add a separator at the end (a line separator), but that is
the case on Linux as well.
Drag-and-dropping a single file results in data which is the path to the
file + a separator.

You can see this in
(which I think where the contents of the transferable on Linux is created).
Line 1391-1395:

                                if (0 != allowedFiles.length())

So even for a single file, the separator is appended.

Note that because you do not know in advance whether the transferable
contains multiple files or not, typical handling code is something like:

    BufferedReader r = new BufferedReader(new StringReader((String)
    String line = null;
    while ((line = r.readLine()) != null) {
        //do something with the line

So while I could get rid of the separator for a single entry, I do not
thing it is needed. And for consistency among different OS, I think it
would even be better to leave the separator in there.


On Fri, Jul 15, 2016 at 2:25 PM, Claes Redestad <claes.redestad at oracle.com>

> Hi,
> this seems wrong as it will add a comma at the end if there's only one
> item.
> Shouldn't this rather be something like:
> sb.append(strings[0]);
> for(int i = 1; i < strings.length; i++) {
> +                    sb.append(separator);
>                      sb.append(strings[i]);
> -                    sb.append(separator);
>                  }
> Thanks!
> /Claes
> On 2016-07-15 14:12, Mikhail Cherkasov wrote:
>> Hi all,
>> Could you please approve integration of the following fix:
>> webrev: http://cr.openjdk.java.net/~rstevens/8160941/webrev.01/
>> jbs: https://bugs.openjdk.java.net/browse/JDK-8160941
>> review:
>> http://mail.openjdk.java.net/pipermail/awt-dev/2016-July/011642.html
>> Thanks,
>> Mikhail.

More information about the jdk8u-dev mailing list