Skip to content

Commit 8847ce3

Browse files
committed
[refactor] add exception debugging within SSLSocket#waitSelect
1 parent 2f251b9 commit 8847ce3

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

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

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,8 @@ else if ((operations & SelectionKey.OP_WRITE) != 0) {
471471
writeWouldBlock(runtime, exception, result);
472472
}
473473
}
474-
}
475-
catch (IOException ioe) {
474+
} catch (IOException ioe) {
475+
debugStackTrace(runtime, "SSLSocket.waitSelect", ioe);
476476
throw runtime.newRuntimeError("Error with selector: " + ioe.getMessage());
477477
}
478478
} else {
@@ -483,6 +483,7 @@ public void run() throws InterruptedException {
483483
result[0] = selector.select();
484484
}
485485
catch (IOException ioe) {
486+
debugStackTrace(runtime, "SSLSocket.waitSelect", ioe);
486487
throw runtime.newRuntimeError("Error with selector: " + ioe.getMessage());
487488
}
488489
}
@@ -505,32 +506,27 @@ public void wakeup() {
505506
//JRuby <= 9.1.2.0 that makes this not always the case, so we have to check
506507
return selector.selectedKeys().contains(key) ? Boolean.TRUE : Boolean.FALSE;
507508
}
508-
}
509-
catch (InterruptedException interrupt) { return Boolean.FALSE; }
510-
finally {
511-
// Note: I don't like ignoring these exceptions, but it's
512-
// unclear how likely they are to happen or what damage we
513-
// might do by ignoring them. Note that the pieces are separate
514-
// so that we can ensure one failing does not affect the others
515-
// running.
509+
} catch (InterruptedException interrupt) {
510+
debug(runtime, "SSLSocket.waitSelect", interrupt);
511+
return Boolean.FALSE;
512+
} finally {
513+
// Note: I don't like ignoring these exceptions, but it's unclear how likely they are to happen or what
514+
// damage we might do by ignoring them. Note that the pieces are separate so that we can ensure one failing
515+
// does not affect the others running.
516516

517517
// clean up the key in the selector
518518
try {
519519
if ( key != null ) key.cancel();
520520
if ( selector != null ) selector.selectNow();
521-
}
522-
catch (Exception e) { // ignore
523-
debugStackTrace(runtime, e);
521+
} catch (Exception e) { // ignore
522+
debugStackTrace(runtime, "SSLSocket.waitSelect (ignored)", e);
524523
}
525524

526525
// shut down and null out the selector
527526
try {
528-
if ( selector != null ) {
529-
runtime.getSelectorPool().put(selector);
530-
}
531-
}
532-
catch (Exception e) { // ignore
533-
debugStackTrace(runtime, e);
527+
if ( selector != null ) runtime.getSelectorPool().put(selector);
528+
} catch (Exception e) { // ignore
529+
debugStackTrace(runtime, "SSLSocket.waitSelect (ignored)", e);
534530
}
535531

536532
if (blocking) {
@@ -810,8 +806,11 @@ private void doShutdown() throws IOException {
810806
flushData(true);
811807
}
812808

813-
private IRubyObject sysreadImpl(final ThreadContext context,
814-
IRubyObject len, IRubyObject buff, final boolean blocking, final boolean exception) {
809+
/**
810+
* @return the (@link RubyString} buffer or :wait_readable / :wait_writeable {@link RubySymbol}
811+
*/
812+
private IRubyObject sysreadImpl(final ThreadContext context, final IRubyObject len, final IRubyObject buff,
813+
final boolean blocking, final boolean exception) {
815814
final Ruby runtime = context.runtime;
816815

817816
final int length = RubyNumeric.fix2int(len);

0 commit comments

Comments
 (0)