Repository navigation
Omit the stacktrace for JOniException - #89
Conversation
|
I am reluctant to remove the stack trace here. As with other potentially-useful stack traces in JRuby (EAGAIN etc), it could be tied to a property check so it can be enabled if needed. Alternatively, since your use case is to use the compilation as a verification step, we could add an API that allows compilation to report an error condition more cheaply than raising an exception. |
|
My thinking is the Java stracktrace would never be useful to a user of JRuby or TruffleRuby (only the Ruby backtrace). What do you think, does that make sense? A system property default no-stacktrace sounds OK, I can do that if you prefer that. This change would make every interaction with JOni which ends up in an exception significantly faster, as said above this accounted for 8% of a Rails request, which is very expensive. |
JOni has consumers other than JRuby and TruffleRuby. I do not know what their expectations are regarding compilation exceptions and stack traces.
It's perhaps less ideal than providing a "trial compilation" or syntax-checking path that doesn't trigger exceptions, but it's the simpler fix to just disable the stack trace and make it configurable. Use property I wish the JVM was better about omitting stack traces for transient throw (this is a perfect case) but alas, here we are.
It appears JRuby also does such a "trial compilation". The Rails patch is good (simplifies stringification of the Regexp) but I agree that a change here is appropriate for unpatched releases. |
1812976 to
2aac297
Compare
…ace=true * The stacktrace is not very useful and is very expensive, for example for Regexp#to_s on a Regexp like /(?i:a)|(?i:b)/. * On ruby-bench's railsbench it accounts for about 8% of the request time. * Rails master has been improved to use #source instead, rails/rails#58678, but that doesn't affect existing releases. * The stacktrace can be re-enabled with the org.joni.enableStackTrace system property, e.g. for debugging JOni itself. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2aac297 to
c409a46
Compare
|
PR updated, the stacktrace is now omitted, unless |
|
I'll put it a release later this evening. Thanks! |
cc @headius