[11u]: RFR: 8215281: Use String.isEmpty() when applicable in java.base

Claes Redestad claes.redestad at oracle.com
Mon Jun 24 08:24:02 UTC 2019


Hi,


On 2019-06-24 09:27, Thomas Stüfe wrote:
> However, your patch (and the original one) contained the following part I
> do not understand:
> 
> http://cr.openjdk.java.net/~clanger/webrevs/8215281.11u/src/java.base/windows/classes/sun/nio/ch/FileDispatcherImpl.java.udiff.html
> 
>       static boolean isFastFileTransferRequested() {
>           String fileTransferProp = GetPropertyAction
> -                .privilegedGetProperty("jdk.nio.enableFastFileTransfer");
> -        boolean enable;
> -        if ("".equals(fileTransferProp)) {
> -            enable = true;
> -        } else {
> -            enable = Boolean.parseBoolean(fileTransferProp);
> -        }
> -        return enable;
> +                .privilegedGetProperty("jdk.nio.enableFastFileTransfer",
> "false");
> +        return fileTransferProp.isEmpty() ? true :
> Boolean.parseBoolean(fileTransferProp);
>       }
> 
> The old version called GetPropertyAction::privilegedGetProperty() without
> default value. The new versions passes "false" as default value. I fail to
> see how this could ever return an empty string? Also, would that not change
> default behavior?

Behavior before and after should be the same.

Both System.getProperty("jdk.nio.enableFastFileTransfer") and
System.getProperty("jdk.nio.enableFastFileTransfer", "false") will
return "" in case -Djdk.nio.enableFastFileTransfer is specified. The
default "false" only changes so that we don't have to deal with
fileTransferProp being null, which I thought made for a nice little
cleanup.

/Claes


More information about the jdk-updates-dev mailing list