@@ -294,48 +294,46 @@ public IRubyObject initialize_copy(IRubyObject obj) {
294294 checkFrozen ();
295295 super .initialize_copy (obj );
296296
297- copyState (getRuntime ().getCurrentContext (), (X509Cert ) obj );
298- return this ;
299- }
300-
301- private void copyState (final ThreadContext context , final X509Cert that ) {
302- final Ruby runtime = context .runtime ;
303-
304- this .subject = copyName (context , that .subject );
305- this .issuer = copyName (context , that .issuer );
306- this .serial = that .serial ;
307- this .not_before = copyTime (runtime , that .not_before );
308- this .not_after = copyTime (runtime , that .not_after );
309- this .sig_alg = that .sig_alg == null ? null : that .sig_alg .dup ();
310- this .version = that .version ;
311- this .cert = copyCertificate (context , that .cert );
312- this .public_key = that .public_key == null ? null : (PKey ) that .public_key .dup ();
297+ final Ruby runtime = getRuntime ();
298+ final X509Cert other = (X509Cert ) obj ;
299+
300+ this .subject = copyName (runtime , other .subject );
301+ this .issuer = copyName (runtime , other .issuer );
302+ this .serial = other .serial ;
303+ this .not_before = copyTime (runtime , other .not_before );
304+ this .not_after = copyTime (runtime , other .not_after );
305+ this .sig_alg = other .sig_alg == null ? null : other .sig_alg .dup ();
306+ this .version = other .version ;
307+ this .cert = copyCertificate (runtime , other .cert );
308+ this .public_key = other .public_key == null ? null : (PKey ) other .public_key .dup ();
313309
314310 this .extensions .clear ();
315- for ( X509Extension ext : that .extensions ) {
311+ for ( X509Extension ext : other .extensions ) {
316312 this .extensions .add ( (X509Extension ) ext .dup () );
317313 }
318314
319- this .changed = that .changed ;
315+ this .changed = other .changed ;
316+
317+ return this ;
320318 }
321319
322- private static IRubyObject copyName (final ThreadContext context , final IRubyObject name ) {
320+ private static IRubyObject copyName (final Ruby runtime , final IRubyObject name ) {
323321 if ( name == null || name .isNil () ) return name ;
324- return X509Name .newName (context . runtime , ((X509Name ) name ).getX500Name ());
322+ return X509Name .newName (runtime , ((X509Name ) name ).getX500Name ());
325323 }
326324
327325 private static RubyTime copyTime (final Ruby runtime , final RubyTime time ) {
328326 return time == null ? null : RubyTime .newTime (runtime , time .getJavaDate ().getTime ());
329327 }
330328
331- private static X509Certificate copyCertificate (final ThreadContext context , final X509Certificate cert ) {
329+ private static X509Certificate copyCertificate (final Ruby runtime , final X509Certificate cert ) {
332330 if ( cert == null ) return null ;
333331 try {
334332 final ByteArrayInputStream bis = new ByteArrayInputStream (cert .getEncoded ());
335333 return (X509Certificate ) SecurityHelper .getCertificateFactory ("X.509" ).generateCertificate (bis );
336334 }
337335 catch (CertificateException e ) {
338- throw newCertificateError (context . runtime , e );
336+ throw newCertificateError (runtime , e );
339337 }
340338 }
341339
0 commit comments