Skip to content

Commit 5a1575a

Browse files
committed
disable backtrace generation for wait non-block errors (use an empty array)
... little more confusing than a `nil` but for now has todo (until jruby/jruby#3488)
1 parent 51ce19c commit 5a1575a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.jruby.runtime.Block;
3939
import org.jruby.runtime.ThreadContext;
4040
import org.jruby.runtime.builtin.IRubyObject;
41+
import org.jruby.util.SafePropertyAccessor;
4142

4243
/**
4344
* @author <a href="mailto:[email protected]">Ola Bini</a>
@@ -177,13 +178,20 @@ public static RaiseException newSSLErrorWaitWritable(Ruby runtime, String messag
177178
return newCustomSSLError(runtime, "SSLErrorWaitWritable", message);
178179
}
179180

181+
// -Djruby.openssl.ssl.error_wait_nonblock.backtrace=false disables backtrace for WaitReadable/Writable
182+
private static final boolean waitErrorBacktrace =
183+
SafePropertyAccessor.getBoolean("jruby.openssl.ssl.error_wait_nonblock.backtrace", false);
184+
180185
private static RaiseException newCustomSSLError(final Ruby runtime, final String name,
181186
final String message) {
182187
RubyClass errorClass = _SSL(runtime).getClass(name);
183188
if ( errorClass == null ) { // < Ruby 2.0
184189
errorClass = _SSL(runtime).getClass("SSLError"); // fallback
185190
}
186-
return Utils.newError(runtime, errorClass, message, false);
191+
if ( waitErrorBacktrace ) {
192+
return Utils.newError(runtime, errorClass, message, false);
193+
}
194+
return Utils.newErrorWithoutTrace(runtime, errorClass, message, false);
187195
}
188196

189197
static RubyModule _SSL(final Ruby runtime) {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ static RaiseException newRuntimeError(Ruby runtime, String msg) {
7070
return new RaiseException(runtime, runtime.getRuntimeError(), msg, true);
7171
}
7272

73+
static RaiseException newErrorWithoutTrace(Ruby runtime, RubyClass errorClass, String message, boolean nativeException) {
74+
final IRubyObject backtrace = runtime.newEmptyArray(); // runtime.getNil();
75+
return new RaiseException(runtime, errorClass, message, backtrace, nativeException);
76+
}
77+
7378
static RaiseException newError(Ruby runtime, RubyClass errorClass, String message, boolean nativeException) {
7479
return new RaiseException(runtime, errorClass, message, nativeException);
7580
}

0 commit comments

Comments
 (0)