Skip to content

Commit 8946b0b

Browse files
committed
[fix] alpn_protocol might return nil
1 parent e7a6656 commit 8946b0b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/java/org/jruby/ext/openssl/SSLSocket.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,9 @@ private SSLEngine ossl_ssl_setup(final ThreadContext context, final boolean serv
242242
public final SSLContext context() { return this.sslContext; }
243243

244244
@JRubyMethod(name = "alpn_protocol")
245-
public final RubyString alpn_protocol(final ThreadContext context) {
246-
return RubyString.newString(context.runtime, this.engine.getApplicationProtocol());
245+
public IRubyObject alpn_protocol(final ThreadContext context) {
246+
final String protocol = engine.getApplicationProtocol();
247+
return protocol == null ? context.nil : RubyString.newString(context.runtime, protocol);
247248
}
248249

249250
@JRubyMethod(name = "sync")

0 commit comments

Comments
 (0)