From 1924cd1456cfd5f893fee459b5034d3225362d9b Mon Sep 17 00:00:00 2001 From: kares Date: Wed, 22 May 2024 19:17:11 +0200 Subject: [PATCH] [refactor] organize i-var sets (set @context after setup) --- src/main/java/org/jruby/ext/openssl/SSLSocket.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jruby/ext/openssl/SSLSocket.java b/src/main/java/org/jruby/ext/openssl/SSLSocket.java index 2b0588b1..408ceca1 100644 --- a/src/main/java/org/jruby/ext/openssl/SSLSocket.java +++ b/src/main/java/org/jruby/ext/openssl/SSLSocket.java @@ -162,19 +162,18 @@ public IRubyObject initialize(final ThreadContext context, final IRubyObject[] a final Ruby runtime = context.runtime; if (Arity.checkArgumentCount(runtime, args, 1, 2) == 1) { - sslContext = new SSLContext(runtime).initializeImpl(); + this.sslContext = new SSLContext(runtime).initializeImpl(); } else { if (!(args[1] instanceof SSLContext)) { throw runtime.newTypeError(args[1], "OpenSSL::SSL::SSLContext"); } - sslContext = (SSLContext) args[1]; + this.sslContext = (SSLContext) args[1]; } if (!(args[0] instanceof RubyIO)) { throw runtime.newTypeError("IO expected but got " + args[0].getMetaClass().getName()); } - setInstanceVariable("@context", this.sslContext); // only compat (we do not use @context) - setInstanceVariable("@io", this.io = (RubyIO) args[0]); + setInstanceVariable("@io", this.io = (RubyIO) args[0]); // RubyBasicSocket extends RubyIO set_io_nonblock_checked(context, runtime.getTrue()); // This is a bit of a hack: SSLSocket should share code with // RubyBasicSocket, which always sets sync to true. @@ -182,6 +181,7 @@ public IRubyObject initialize(final ThreadContext context, final IRubyObject[] a set_sync(context, runtime.getTrue()); // io.sync = true setInstanceVariable("@sync_close", runtime.getFalse()); // self.sync_close = false sslContext.setup(context); + setInstanceVariable("@context", sslContext); // only compat (we do not use @context) this.initializeTime = System.currentTimeMillis();