Skip to content

Commit

Permalink
disable backtrace generation for wait non-block errors (use an empty …
Browse files Browse the repository at this point in the history
…array)

... little more confusing than a `nil` but for now has todo (until jruby/jruby#3488)
kares committed Dec 17, 2015
1 parent 51ce19c commit 5a1575a
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/java/org/jruby/ext/openssl/SSL.java
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@
import org.jruby.runtime.Block;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.SafePropertyAccessor;

/**
* @author <a href="mailto:ola.bini@ki.se">Ola Bini</a>
@@ -177,13 +178,20 @@ public static RaiseException newSSLErrorWaitWritable(Ruby runtime, String messag
return newCustomSSLError(runtime, "SSLErrorWaitWritable", message);
}

// -Djruby.openssl.ssl.error_wait_nonblock.backtrace=false disables backtrace for WaitReadable/Writable
private static final boolean waitErrorBacktrace =
SafePropertyAccessor.getBoolean("jruby.openssl.ssl.error_wait_nonblock.backtrace", false);

private static RaiseException newCustomSSLError(final Ruby runtime, final String name,
final String message) {
RubyClass errorClass = _SSL(runtime).getClass(name);
if ( errorClass == null ) { // < Ruby 2.0
errorClass = _SSL(runtime).getClass("SSLError"); // fallback
}
return Utils.newError(runtime, errorClass, message, false);
if ( waitErrorBacktrace ) {
return Utils.newError(runtime, errorClass, message, false);
}
return Utils.newErrorWithoutTrace(runtime, errorClass, message, false);
}

static RubyModule _SSL(final Ruby runtime) {
5 changes: 5 additions & 0 deletions src/main/java/org/jruby/ext/openssl/Utils.java
Original file line number Diff line number Diff line change
@@ -70,6 +70,11 @@ static RaiseException newRuntimeError(Ruby runtime, String msg) {
return new RaiseException(runtime, runtime.getRuntimeError(), msg, true);
}

static RaiseException newErrorWithoutTrace(Ruby runtime, RubyClass errorClass, String message, boolean nativeException) {
final IRubyObject backtrace = runtime.newEmptyArray(); // runtime.getNil();
return new RaiseException(runtime, errorClass, message, backtrace, nativeException);
}

static RaiseException newError(Ruby runtime, RubyClass errorClass, String message, boolean nativeException) {
return new RaiseException(runtime, errorClass, message, nativeException);
}

0 comments on commit 5a1575a

Please sign in to comment.