action_subscriber 4.4.0.pre2-java → 4.5.0-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6fe3e9f8efec05473fbfdf80470c830571a3fbf443791c4a1ba2b734b3180056
4
- data.tar.gz: fd5f12b1e85d98e6d22583a42bf9f7e23c3b534f00ee60e13814107b3c049c39
3
+ metadata.gz: 2e5ccb8aef3395279c11bfafe6dcac47c88d653981dee2935b67234918978327
4
+ data.tar.gz: 3111f0950b69c540cf101c6d9ed9ded217d2d1f8c1d7fe808fbaf1ec5f106b2f
5
5
  SHA512:
6
- metadata.gz: 3ae40be01a43d34bcfbf6c1529ade82c8a6bffd78780810a6a4b1a4218b10702247b3cbdae1cbbda78cbc9ca083d35f897e75efa9f95173ef80556991ad9599a
7
- data.tar.gz: 7a1fcdd05959cc0bc1a2121f48ec5257f0d1826343fcbe21233fd23cadb2bb71588e6eed7570d61e3cad1aaaf76724ed358f3927fe04b9460c4156c30f2e7946
6
+ metadata.gz: 0d497d0bc6eeeffc3b5f06c159ae782a3767cf351f1e7542f79f98c04d4226230edcedfa25b668b3f3826a886b1ba707ba36050fa2cf6629e98f41da6a290c16
7
+ data.tar.gz: 3dac444e91c7bfb63aa77b5cff0c94c6ba1244d2e5669d6d7b4b1c5f974343087cc44f823cc4329738de16fc724f308a77cd751018b1838763435e655067a767
@@ -85,7 +85,13 @@ module ActionSubscriber
85
85
  'text/plain' => lambda { |payload| payload.dup }
86
86
  }
87
87
 
88
- self.error_handler = lambda { |error, env_hash| raise }
88
+ self.error_handler = lambda do |error, env_hash|
89
+ logger = ::ActionSubscriber::Logging.logger
90
+
91
+ logger.error(error.message)
92
+ logger.error(error.class.to_s)
93
+ logger.error(error.backtrace.join("\n")) if error.try(:backtrace) && error.backtrace.is_a?(::Array)
94
+ end
89
95
 
90
96
  DEFAULTS.each_pair do |key, value|
91
97
  self.__send__("#{key}=", value)
@@ -8,25 +8,18 @@ module ActionSubscriber
8
8
  end
9
9
 
10
10
  def call(env)
11
- job_mutex = ::Mutex.new
12
- job_complete = ::ConditionVariable.new
11
+ @app.call(env)
12
+ rescue => error
13
+ logger.error "FAILED #{env.message_id}"
13
14
 
14
- job_mutex.synchronize do
15
- ::Thread.new do
16
- job_mutex.synchronize do
17
- begin
18
- @app.call(env)
19
- rescue => error
20
- logger.error "FAILED #{env.message_id}"
21
- ::ActionSubscriber.configuration.error_handler.call(error, env.to_h)
22
- ensure
23
- job_complete.signal
24
- end
25
- end
26
- end
27
-
28
- # TODO we might want to pass a timeout to this wait so we can handle jobs that get frozen
29
- job_complete.wait(job_mutex)
15
+ # There is more to this rescue than meets the eye. MarchHare's java library will rescue errors
16
+ # and attempt to close the channel with its default exception handler. To avoid this, we will
17
+ # stop errors right here. If you want to handle errors, you must do it in the error handler and
18
+ # it should not re-raise. As a bonus, not killing these threads is better for your runtime :).
19
+ begin
20
+ ::ActionSubscriber.configuration.error_handler.call(error, env.to_h)
21
+ rescue => error
22
+ logger.error "ActionSubscriber error handler raised error, but should never raise. Error: #{error}"
30
23
  end
31
24
  end
32
25
  end
@@ -1,3 +1,3 @@
1
1
  module ActionSubscriber
2
- VERSION = "4.4.0.pre2"
2
+ VERSION = "4.5.0"
3
3
  end
@@ -43,4 +43,21 @@ describe ::ActionSubscriber::Configuration do
43
43
  expect(subject.virtual_host).to eq("vhost")
44
44
  end
45
45
  end
46
+
47
+ describe "error_handler" do
48
+ let(:logger) { ::ActionSubscriber::Logging.logger }
49
+
50
+ it "by default logs the error" do
51
+ expect(logger).to receive(:error).with("I'm confused")
52
+ expect(logger).to receive(:error).with("ArgumentError")
53
+ # Lame way of looking for the backtrace.
54
+ expect(logger).to receive(:error).with(/\.rb/)
55
+
56
+ begin
57
+ fail ::ArgumentError, "I'm confused"
58
+ rescue => error
59
+ subject.error_handler.call(error, {})
60
+ end
61
+ end
62
+ end
46
63
  end
@@ -19,19 +19,4 @@ describe ActionSubscriber::Middleware::ErrorHandler do
19
19
  subject.call(env)
20
20
  end
21
21
  end
22
-
23
- context "many concurrent threads" do
24
- it "handles the race conditions without raising exceptions" do
25
- no_op = lambda{ nil }
26
- threads = 1.upto(100).map do
27
- ::Thread.new do
28
- ::Thread.current.abort_on_exception = true
29
- 100.times do
30
- described_class.new(no_op).call(env)
31
- end
32
- end
33
- end
34
- threads.each(&:join)
35
- end
36
- end
37
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_subscriber
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.0.pre2
4
+ version: 4.5.0
5
5
  platform: java
6
6
  authors:
7
7
  - Brian Stien
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2017-07-27 00:00:00.000000000 Z
15
+ date: 2017-08-15 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  requirement: !ruby/object:Gem::Requirement
@@ -277,9 +277,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
277
277
  version: '0'
278
278
  required_rubygems_version: !ruby/object:Gem::Requirement
279
279
  requirements:
280
- - - ">"
280
+ - - ">="
281
281
  - !ruby/object:Gem::Version
282
- version: 1.3.1
282
+ version: '0'
283
283
  requirements: []
284
284
  rubyforge_project:
285
285
  rubygems_version: 2.6.11