vendored/puppet/lib/puppet/util/json_lockfile.rb in bolt-0.20.3 vs vendored/puppet/lib/puppet/util/json_lockfile.rb in bolt-0.20.5
- old
+ new
@@ -21,11 +21,11 @@
# serialized as Strings, so you should plan accordingly.
# @return [boolean] true if lock is successfully acquired, false otherwise.
def lock(lock_data = nil)
return false if locked?
- super(lock_data.to_json)
+ super(Puppet::Util::Json.dump(lock_data))
end
# Retrieve the (optional) lock data that was specified at the time the file
# was locked.
# @return [Object] the data object. Remember that the serialization does not
@@ -33,11 +33,11 @@
# they will be converted to Strings.
def lock_data
return nil unless file_locked?
file_contents = super
return nil if file_contents.nil? or file_contents.empty?
- JSON.parse(file_contents)
- rescue JSON::ParserError
+ Puppet::Util::Json.load(file_contents)
+ rescue Puppet::Util::Json::ParseError
Puppet.warning _("Unable to read lockfile data from %{path}: not in JSON") % { path: @file_path }
nil
end
end