@@ -554,20 +554,8 @@ def createRackServletWrapper(runtime, rackup, filename)
554554
555555describe org . jruby . rack . PoolingRackApplicationFactory do
556556
557- # Workaround rspec mocks/proxies not being thread-safe which causes occasional failures
558- class Synchronized
559- def initialize ( obj )
560- @delegate = obj
561- @lock = Mutex . new
562- end
563-
564- def method_missing ( name , *args , &block )
565- @lock . synchronize { @delegate . send ( name , *args , &block ) }
566- end
567- end
568-
569557 before :each do
570- @factory = Synchronized . new ( double ( "factory" ) . as_null_object )
558+ @factory = double ( "factory" ) . as_null_object
571559 @pooling_factory = org . jruby . rack . PoolingRackApplicationFactory . new @factory
572560 @pooling_factory . context = @rack_context
573561 end
@@ -617,7 +605,7 @@ def method_missing(name, *args, &block)
617605 it "creates applications during initialization according to the jruby.min.runtimes context parameter" do
618606 allow ( @factory ) . to receive ( :init )
619607 allow ( @factory ) . to receive ( :newApplication ) do
620- app = Synchronized . new ( double ( "app" ) . as_null_object )
608+ app = double ( "app" ) . as_null_object
621609 expect ( app ) . to receive ( :init )
622610 app
623611 end
@@ -650,7 +638,7 @@ def method_missing(name, *args, &block)
650638 it "forces the maximum size to be greater or equal to the initial size" do
651639 allow ( @factory ) . to receive ( :init )
652640 allow ( @factory ) . to receive ( :newApplication ) do
653- app = Synchronized . new ( double ( "app" ) . as_null_object )
641+ app = double ( "app" ) . as_null_object
654642 expect ( app ) . to receive ( :init )
655643 app
656644 end
@@ -672,7 +660,7 @@ def method_missing(name, *args, &block)
672660 it "waits till initial runtimes get initialized (with wait set to true)" do
673661 allow ( @factory ) . to receive ( :init )
674662 allow ( @factory ) . to receive ( :newApplication ) do
675- app = Synchronized . new ( double ( "app" ) . as_null_object )
663+ app = double ( "app" ) . as_null_object
676664 allow ( app ) . to receive ( :init ) do
677665 sleep ( 0.05 )
678666 end
@@ -692,7 +680,7 @@ def method_missing(name, *args, &block)
692680 allow ( @factory ) . to receive ( :init )
693681 app_count = java . util . concurrent . atomic . AtomicInteger . new ( 0 )
694682 allow ( @factory ) . to receive ( :newApplication ) do
695- app = Synchronized . new ( double ( "app" ) . as_null_object )
683+ app = double ( "app" ) . as_null_object
696684 allow ( app ) . to receive ( :init ) do
697685 if app_count . addAndGet ( 1 ) == 2
698686 raise org . jruby . rack . RackInitializationException . new ( 'failed app init' )
@@ -730,7 +718,7 @@ def method_missing(name, *args, &block)
730718 app_init_secs = 0.2
731719 allow ( @factory ) . to receive ( :init )
732720 allow ( @factory ) . to receive ( :newApplication ) do
733- app = Synchronized . new ( double ( "app" ) . as_null_object )
721+ app = double ( "app" ) . as_null_object
734722 allow ( app ) . to receive ( :init ) { sleep ( app_init_secs ) }
735723 app
736724 end
@@ -748,7 +736,7 @@ def method_missing(name, *args, &block)
748736 app_init_secs = 0.2
749737 allow ( @factory ) . to receive ( :init )
750738 expect ( @factory ) . to receive ( :newApplication ) . twice do
751- app = Synchronized . new ( double ( "app" ) . as_null_object )
739+ app = double ( "app" ) . as_null_object
752740 expect ( app ) . to receive ( :init ) { sleep ( app_init_secs ) }
753741 app
754742 end
@@ -777,7 +765,7 @@ def method_missing(name, *args, &block)
777765 app_init_secs = 0.1
778766 allow ( @factory ) . to receive ( :init )
779767 expect ( @factory ) . to receive ( :newApplication ) . twice do
780- app = Synchronized . new ( double ( "app (new)" ) . as_null_object )
768+ app = double ( "app (new)" ) . as_null_object
781769 expect ( app ) . to receive ( :init ) { sleep ( app_init_secs ) }
782770 app
783771 end
@@ -793,7 +781,7 @@ def method_missing(name, *args, &block)
793781
794782 app_get_secs = 0.15
795783 expect ( @factory ) . to receive ( :getApplication ) . twice do
796- app = Synchronized . new ( double ( "app (get)" ) . as_null_object )
784+ app = double ( "app (get)" ) . as_null_object
797785 sleep ( app_get_secs )
798786 app
799787 end
@@ -813,7 +801,7 @@ def method_missing(name, *args, &block)
813801 app_init_secs = 0.15
814802 allow ( @factory ) . to receive ( :init )
815803 allow ( @factory ) . to receive ( :newApplication ) do
816- app = Synchronized . new ( double ( "app" ) . as_null_object )
804+ app = double ( "app" ) . as_null_object
817805 allow ( app ) . to receive ( :init ) { sleep ( app_init_secs ) }
818806 app
819807 end
@@ -840,7 +828,7 @@ def method_missing(name, *args, &block)
840828 app_init_secs = 0.05
841829 allow ( @factory ) . to receive ( :init )
842830 allow ( @factory ) . to receive ( :newApplication ) do
843- app = Synchronized . new ( double ( "app" ) . as_null_object )
831+ app = double ( "app" ) . as_null_object
844832 allow ( app ) . to receive ( :init ) { sleep ( app_init_secs ) ; raise "app.init raising" }
845833 app
846834 end
0 commit comments