Skip to content

Commit

Permalink
Fix warnings and circular reference crash
Browse files Browse the repository at this point in the history
Fixes #254
  • Loading branch information
kattrali committed Nov 16, 2015
2 parents 6348306 + 2f174b4 commit a041d1f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
14 changes: 6 additions & 8 deletions lib/bugsnag/delivery/thread_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@ class << self
def deliver(url, body, configuration)
start_once!

if queue.length > MAX_OUTSTANDING_REQUESTS
Bugsnag.warn("Dropping notification, #{queue.length} outstanding requests")
if @queue.length > MAX_OUTSTANDING_REQUESTS
Bugsnag.warn("Dropping notification, #{@queue.length} outstanding requests")
return
end

# Add delivery to the worker thread
queue.push proc { super(url, body, configuration) }
@queue.push proc { super(url, body, configuration) }
end

private

attr_reader :queue

def start_once!
MUTEX.synchronize do
return if @started
Expand All @@ -32,15 +30,15 @@ def start_once!
@queue = Queue.new

worker_thread = Thread.new do
while x = queue.pop
while x = @queue.pop
break if x == STOP
x.call
end
end

at_exit do
Bugsnag.warn("Waiting for #{queue.length} outstanding request(s)") unless queue.empty?
queue.push STOP
Bugsnag.warn("Waiting for #{@queue.length} outstanding request(s)") unless @queue.empty?
@queue.push STOP
worker_thread.join
end
end
Expand Down
1 change: 0 additions & 1 deletion lib/bugsnag/deploy.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require "bugsnag"
require "json"

module Bugsnag
Expand Down
2 changes: 1 addition & 1 deletion lib/bugsnag/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Notification
CURRENT_PAYLOAD_VERSION = "2"

attr_accessor :context
attr_accessor :user
attr_reader :user
attr_accessor :configuration
attr_accessor :meta_data

Expand Down
10 changes: 5 additions & 5 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ def notify_test_exception(*args)
WebMock.stub_request(:post, "https://notify.bugsnag.com/")

Bugsnag.instance_variable_set(:@configuration, Bugsnag::Configuration.new)
Bugsnag.configure do |config|
config.api_key = "c9d60ae4c7e70c4b6c4ebd3e8056d2b8"
config.release_stage = "production"
config.delivery_method = :synchronous
Bugsnag.configure do |bugsnag|
bugsnag.api_key = "c9d60ae4c7e70c4b6c4ebd3e8056d2b8"
bugsnag.release_stage = "production"
bugsnag.delivery_method = :synchronous
# silence logger in tests
config.logger = Logger.new(StringIO.new)
bugsnag.logger = Logger.new(StringIO.new)
end
end

Expand Down

0 comments on commit a041d1f

Please sign in to comment.