File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -483,7 +483,7 @@ private void captureMessage(final RaiseException re) {
483483 rubyException .callMethod (context , "capture" );
484484 rubyException .callMethod (context , "store" );
485485 }
486- catch (Exception e ) {
486+ catch (Throwable e ) {
487487 rackContext .log (INFO , "failed to capture exception message" , e );
488488 // won't be able to capture anything
489489 }
Original file line number Diff line number Diff line change @@ -487,6 +487,40 @@ def reset_config
487487 expect ( e . message ) . to eql 'something went wrong'
488488 end
489489 end
490+
491+ it "swallows and logs errors during exception detail capturing" do
492+ expect ( @rack_config ) . to receive ( :getRackup ) . and_return ( "raise 'something went wrong'" )
493+ expect_any_instance_of ( Exception ) . to receive ( :capture ) . and_raise java . lang . NoClassDefFoundError . new ( "missing class during exception capture" )
494+
495+ app_factory = mocked_runtime_application_factory
496+ app_factory . init @rack_context
497+ app_object = app_factory . newApplication
498+
499+ raise_info_logged = 0
500+ raise_error_logged = 0
501+ allow ( @rack_context ) . to receive ( :log ) do |level , msg , e |
502+ if level . to_s == 'INFO'
503+ expect ( msg ) . to eql 'failed to capture exception message'
504+ expect ( e ) . to be_a java . lang . NoClassDefFoundError
505+ raise_info_logged += 1
506+ elsif level . to_s == 'ERROR'
507+ expect ( msg ) . to eql 'unable to initialize application'
508+ expect ( e ) . to be_a org . jruby . exceptions . RaiseException
509+ raise_error_logged += 1
510+ else
511+ true
512+ end
513+ end
514+
515+ begin
516+ app_object . init
517+ fail "expected to raise"
518+ rescue => e
519+ expect ( e . message ) . to eql 'something went wrong'
520+ end
521+
522+ expect ( raise_info_logged ) . to eql 1 # logs info message for exception capture
523+ end
490524 end
491525
492526 describe "getApplication" do
You can’t perform that action at this time.
0 commit comments