jruby / jcodings

Java-based codings helper classes for Joni and JRuby
MIT License
21 stars 29 forks source link

Should encoding exceptions capture the stack trace #41

Closed chrisseaton closed 3 years ago

chrisseaton commented 3 years ago

We know that encoding exceptions occur in the fast path, https://github.com/jruby/jruby/issues/6652, so should we disable the Java stack trace in JCodings exceptions?

https://github.com/jruby/jcodings/blob/master/src/org/jcodings/exception/JCodingsException.java

@eregon

eregon commented 3 years ago

Removing the Java stacktrace can be problematic for debugging though. I think ideally we would have a checked exception variant that does not capture a stacktrace, and then some of the JCodings methods could have a variant throwing that checked exception instead, like Encoding#codeToMbcLength().

eregon commented 3 years ago

Actually Encoding#codeToMbcLength() seems to never throw an exception, so the caller code was probably too defensive.

eregon commented 3 years ago

I think we can close, besides that one case where it's not needed, TruffleRuby does not catch any JCodings exception (git grep -F org.jcodings.exception).

chrisseaton commented 3 years ago

Ok apologies for the noise I'll dig a bit further as I thought this was the performance issue.