java.net.http orElse(null) in SSLDelegate and other nits
Bernd Eckenfels
ecki at zusammenkunft.net
Sat Aug 27 16:25:12 UTC 2016
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();
}
seems to use a Optional anti-pattern. How about:
SSLParameters sslp = client.sslParameters().orElseGet(context::getSupportedSSLParameters);
(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));
Gruss
Bernd
More information about the net-dev
mailing list