java.net.http orElse(null) in SSLDelegate and other nits
Chris Hegarty
chris.hegarty at oracle.com
Thu Sep 1 09:14:44 UTC 2016
Thanks for reporting these issues Bernd,
> On 27 Aug 2016, at 17:25, Bernd Eckenfels <ecki at zusammenkunft.net> wrote:
>
> Hello,
>
> trying to understand the new jdk9 hierachy I noticed that this code:
>
> http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/ca7fb78b94b6/src/java.httpclient/share/classes/java/net/http/SSLDelegate.java#l59
>
> SSLParameters sslp = client.sslParameters().orElse(null);
> if (sslp == null) {
> sslp = context.getSupportedSSLParameters();
> }
Ugh!
> seems to use a Optional anti-pattern. How about:
>
> SSLParameters sslp = client.sslParameters().orElseGet(context::getSupportedSSLParameters);
That is much cleaner.
http://hg.openjdk.java.net/jdk9/sandbox/jdk/rev/9e00f30e37ca
> (If there is a reason for not using lambda, it might need a comment?)
>
> Also I wonder if this parameter conversion and string concatenation should be conditional?
>
> Log.logSSL("Setting application protocols: " + Arrays.toString(alpn));
Yes.
http://hg.openjdk.java.net/jdk9/sandbox/jdk/rev/095cb9252d94
Both of these changes are in the http-client-branch of the sandbox and will
make it into jdk9/dev in the next integration.
Thanks again,
-Chris.
More information about the net-dev
mailing list