@@ -59,17 +59,27 @@ public class SSL {
59
59
public static final long OP_NETSCAPE_CA_DN_BUG = 0x20000000L ;
60
60
public static final long OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG = 0x40000000L ;
61
61
62
+ private static IRubyObject getConstantFromIO (Ruby runtime , String name ) {
63
+ try {
64
+ return runtime .getIO ().getConstant (name );
65
+ }
66
+ catch (Exception e ) {
67
+ e .printStackTrace ();
68
+ return null ;
69
+ }
70
+ }
71
+
62
72
public static void createSSL (final Ruby runtime , final RubyModule ossl ) {
63
73
final RubyModule _SSL = ossl .defineModuleUnder ("SSL" );
64
74
final RubyClass _OpenSSLError = ossl .getClass ("OpenSSLError" );
65
75
RubyClass _SSLError = _SSL .defineClassUnder ("SSLError" , _OpenSSLError , _OpenSSLError .getAllocator ());
66
76
67
- final IRubyObject _WaitReadable = runtime . getIO (). getConstant ( "WaitReadable" );
77
+ final IRubyObject _WaitReadable = getConstantFromIO ( runtime , "WaitReadable" );
68
78
if ( _WaitReadable != null ) { // since 2.0 (do not exist in 1.8 / 1.9)
69
79
_SSL .defineClassUnder ("SSLErrorWaitReadable" , _SSLError , _OpenSSLError .getAllocator ()).
70
80
include (new IRubyObject []{ _WaitReadable });
71
81
}
72
- final IRubyObject _WaitWritable = runtime . getIO (). getConstant ( "WaitWritable" );
82
+ final IRubyObject _WaitWritable = getConstantFromIO ( runtime , "WaitWritable" );
73
83
if ( _WaitWritable != null ) { // since 2.0 (do not exist in 1.8 / 1.9)
74
84
_SSL .defineClassUnder ("SSLErrorWaitWritable" , _SSLError , _OpenSSLError .getAllocator ()).
75
85
include (new IRubyObject []{ _WaitWritable });
0 commit comments