Skip to content

(#17887) Only log if message has been initialized#1358

Closed
domcleal wants to merge 1 commit intopuppetlabs:masterfrom
domcleal:tickets/master/17887-resource-log-msg
Closed

(#17887) Only log if message has been initialized#1358
domcleal wants to merge 1 commit intopuppetlabs:masterfrom
domcleal:tickets/master/17887-resource-log-msg

Conversation

@domcleal
Copy link
Contributor

It's possible to run the "ensure" block without having executed either the
main or "rescue" blocks, if an Exception not derived from StandardError is
raised or when testing with Mocha expectations.

If this happens during the property.sync, this causes an immediate exit from
the main block, but the "ensure" block is still run. The event message won't
have been initialized yet, so this then causes the logger to report:

Puppet::Util::Log requires a message

This changes the "ensure" block to only log if it's got as far as writing a
message.

Replaces GH-1307 to rebase against master and add a test.

It's possible to run the "ensure" block without having executed either the
main or "rescue" blocks, if an Exception not derived from StandardError is
raised or when testing with Mocha expectations.

If this happens during the property.sync, this causes an immediate exit from
the main block, but the "ensure" block is still run.  The event message won't
have been initialized yet, so this then causes the logger to report:

  Puppet::Util::Log requires a message

This changes the "ensure" block to only log if it's got as far as writing a
message.
@joshcooper
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants