Skip to content

Commit

Permalink
[refactor] organize i-var sets (set @context after setup)
Browse files Browse the repository at this point in the history
  • Loading branch information
kares committed May 22, 2024
1 parent d97d868 commit 1924cd1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/java/org/jruby/ext/openssl/SSLSocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,26 +162,26 @@ 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.
// Instead we set it here for now.
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();

Expand Down

0 comments on commit 1924cd1

Please sign in to comment.