-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Description
I'm getting a NPE when I use OkHttpChannelBuilder with ConnectionSpec.CLEARTEXT. I might be misusing the API, but I think it's actually an issue.
ConnectionSpec connectionSpec = new ConnectionSpec.Builder(ConnectionSpec.CLEARTEXT).build();
ManagedChannelImpl channel = OkHttpChannelBuilder.forAddress(host, port).connectionSpec(connectionSpec).build();
The problem is that Utils.convertSpec is calling spec.tlsVersions:
static ConnectionSpec convertSpec(com.squareup.okhttp.ConnectionSpec spec) {
List<com.squareup.okhttp.TlsVersion> tlsVersionList = spec.tlsVersions();
And spec.tlsVersions assumes tlsVersions is non-null:
public List<TlsVersion> tlsVersions() {
TlsVersion[] result = new TlsVersion[tlsVersions.length];
But tlsVersions is always null (and enforced to be so) if not using TLS.
If this isn't me doing something wrong, I'm happy to send a patch. I guess the patch should be to check whether TLS is enabled before calling tlsVersions, in Utils.