Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Fix for NoMethodError: undefined method `emit' for nil:NilClass error… #45

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hugegreenbug
Copy link

Fix for NoMethodError: undefined method `emit' for nil:NilClass errors with bunny 2.6.4 when exiting fluentd

router.emit(parse_tag(delivery, meta), parse_time(meta), payload)
unless router.nil?
router.emit(parse_tag(delivery, meta), parse_time(meta), payload)
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

end at 84, 8 is not aligned with unless at 82, 1.

@@ -79,7 +79,9 @@ def start
q.subscribe do |delivery, meta, msg|
log.debug "Recieved message #{@msg}"
payload = parse_payload(msg)
router.emit(parse_tag(delivery, meta), parse_time(meta), payload)
unless router.nil?
router.emit(parse_tag(delivery, meta), parse_time(meta), payload)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use 2 (not 9) spaces for indentation.

@@ -79,7 +79,9 @@ def start
q.subscribe do |delivery, meta, msg|
log.debug "Recieved message #{@msg}"
payload = parse_payload(msg)
router.emit(parse_tag(delivery, meta), parse_time(meta), payload)
unless router.nil?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tab detected.
Inconsistent indentation detected.
Use safe navigation (&.) instead of checking if an object exists before calling the method.

@coveralls
Copy link

coveralls commented Mar 29, 2017

Coverage Status

Coverage decreased (-0.2%) to 91.398% when pulling 3802dea on hugegreenbug:master into b1f9355 on giraffi:master.

@coveralls
Copy link

coveralls commented Mar 29, 2017

Coverage Status

Coverage decreased (-0.2%) to 91.398% when pulling 3802dea on hugegreenbug:master into b1f9355 on giraffi:master.

@warmfusion
Copy link
Collaborator

Should we perhaps unsubscribe explicitly in the shutdown method so that the block is terminated cleanly.

Or at least return before parsing the payload to save CPU cycles?

Do you always see this error ?

@warmfusion
Copy link
Collaborator

I'm concerned that this implementation will result in message loss during shutdown as the message will have been consumed off the broker, and as we dont use ack'd message handling if the router.nil? is fired it'd silently drop the event (andperhaps others if there are other circumstances where router is nil...

Perhaps shutting down the broker connection before the router can become nil, or implementing a brief nack/ack handler for the router.emit might be solve that?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants