forked from ruby/rake
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suppress .java sources from exceptions on JRuby #213
Milestone
Comments
Does |
Looks like @headius how about this patch, does diff --git a/lib/rake/backtrace.rb b/lib/rake/backtrace.rb
index 63d2532..439255d 100644
--- a/lib/rake/backtrace.rb
+++ b/lib/rake/backtrace.rb
@@ -9,6 +9,9 @@ module Rake
map { |f| File.expand_path(f) }.
reject { |s| s.nil? || s =~ /^ *$/ }
SUPPRESSED_PATHS_RE = SUPPRESSED_PATHS.map { |f| Regexp.quote(f) }.join("|")
+ SUPPRESSED_PATHS_RE << "|^org\\/jruby\\/\\w+\\.java" if
+ Object.const_defined?(:RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
+
SUPPRESS_PATTERN = %r!(\A(#{SUPPRESSED_PATHS_RE})|bin/rake:\d+)!i
def self.collapse(backtrace) |
With the above patch I get this output:
|
And with
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On JRuby, exception traces can often have .java sources in them. We provide this as a service to help JRuby users know when the error passes through "native" code. These files are presented using JRuby's own package structure as their path, and I believe this confuses the Rake output.
However, on Rake these lines show whenever there's a failing build, since the logic for suppressing uninteresting exception lines does not filter out sources from our Java package.
An example:
For a simple error-causing task:
The following output on JRuby:
The org/jruby/ lines from the backtrace are not filtered out, and are displayed even without --trace.
The logic is from application.rb:
Which calls backtrace.rb:
Which uses the following pattern on my system (SUPPRESS_PATTERN):
Obviously this logic is intending to filter out system files from the backtrace, but it only considers Ruby's core load paths.
On JRuby, we have fixed this in our own Rakefile by adding these lines:
But this is not foolproof since there may be code in other packages that shows up in our backtrace (and our users would have to also add it to their Rakefiles).
I'm not sure what the best fix would be. Rake versions used to use #caller's backtrace for this output, which JRuby scrubs of all .java lines (for compatibility). We could potentially provide a utility that can turn an Exception backtrace into a caller backtrace, but it would not be standard. Alternatively, we could filter out all .java lines, but that would filter out user code that calls through Java (which I believe this new pattern was designed to allow through).
Thoughts?
The text was updated successfully, but these errors were encountered: