File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -439,7 +439,7 @@ private void captureMessage(final RaiseException re) {
439439 rubyException .callMethod (context , "capture" );
440440 rubyException .callMethod (context , "store" );
441441 }
442- catch (Exception e ) {
442+ catch (Throwable e ) {
443443 rackContext .log (INFO , "failed to capture exception message" , e );
444444 // won't be able to capture anything
445445 }
Original file line number Diff line number Diff line change @@ -476,6 +476,40 @@ def reset_config
476476 expect ( e . message ) . to eql 'something went wrong'
477477 end
478478 end
479+
480+ it "swallows and logs errors during exception detail capturing" do
481+ expect ( @rack_config ) . to receive ( :getRackup ) . and_return ( "raise 'something went wrong'" )
482+ expect_any_instance_of ( Exception ) . to receive ( :capture ) . and_raise java . lang . NoClassDefFoundError . new ( "missing class during exception capture" )
483+
484+ app_factory = mocked_runtime_application_factory
485+ app_factory . init @rack_context
486+ app_object = app_factory . newApplication
487+
488+ raise_info_logged = 0
489+ raise_error_logged = 0
490+ allow ( @rack_context ) . to receive ( :log ) do |level , msg , e |
491+ if level . to_s == 'INFO'
492+ expect ( msg ) . to eql 'failed to capture exception message'
493+ expect ( e ) . to be_a java . lang . NoClassDefFoundError
494+ raise_info_logged += 1
495+ elsif level . to_s == 'ERROR'
496+ expect ( msg ) . to eql 'unable to initialize application'
497+ expect ( e ) . to be_a org . jruby . exceptions . RaiseException
498+ raise_error_logged += 1
499+ else
500+ true
501+ end
502+ end
503+
504+ begin
505+ app_object . init
506+ fail "expected to raise"
507+ rescue => e
508+ expect ( e . message ) . to eql 'something went wrong'
509+ end
510+
511+ expect ( raise_info_logged ) . to eql 1 # logs info message for exception capture
512+ end
479513 end
480514
481515 describe "getApplication" do
You can’t perform that action at this time.
0 commit comments