Skip to content

Commit cc63708

Browse files
mkristiankares
authored andcommitted
make sure we have IO::WaitReadable and IO::WaitWritable with 1.8 mode
[skip ci]
1 parent 2fe8c04 commit cc63708

File tree

1 file changed

+12
-2
lines changed
  • src/main/java/org/jruby/ext/openssl

1 file changed

+12
-2
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,27 @@ public class SSL {
5959
public static final long OP_NETSCAPE_CA_DN_BUG = 0x20000000L;
6060
public static final long OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG = 0x40000000L;
6161

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+
6272
public static void createSSL(final Ruby runtime, final RubyModule ossl) {
6373
final RubyModule _SSL = ossl.defineModuleUnder("SSL");
6474
final RubyClass _OpenSSLError = ossl.getClass("OpenSSLError");
6575
RubyClass _SSLError = _SSL.defineClassUnder("SSLError", _OpenSSLError, _OpenSSLError.getAllocator());
6676

67-
final IRubyObject _WaitReadable = runtime.getIO().getConstant("WaitReadable");
77+
final IRubyObject _WaitReadable = getConstantFromIO(runtime, "WaitReadable");
6878
if ( _WaitReadable != null ) { // since 2.0 (do not exist in 1.8 / 1.9)
6979
_SSL.defineClassUnder("SSLErrorWaitReadable", _SSLError, _OpenSSLError.getAllocator()).
7080
include(new IRubyObject[]{ _WaitReadable });
7181
}
72-
final IRubyObject _WaitWritable = runtime.getIO().getConstant("WaitWritable");
82+
final IRubyObject _WaitWritable = getConstantFromIO(runtime, "WaitWritable");
7383
if ( _WaitWritable != null ) { // since 2.0 (do not exist in 1.8 / 1.9)
7484
_SSL.defineClassUnder("SSLErrorWaitWritable", _SSLError, _OpenSSLError.getAllocator()).
7585
include(new IRubyObject[]{ _WaitWritable });

0 commit comments

Comments
 (0)