From: Aki Tuomi Date: Thu, 6 Feb 2014 11:30:06 +0000 (+0200) Subject: Catch conversion error and ignore it for logging X-Git-Tag: rec-3.6.0-rc1~194^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cd01e54a8230025441cbe1a3e05c116596ec8b75;p=pdns Catch conversion error and ignore it for logging --- diff --git a/modules/remotebackend/unittest_http.rb b/modules/remotebackend/unittest_http.rb index e4a579ec1..1a304d040 100755 --- a/modules/remotebackend/unittest_http.rb +++ b/modules/remotebackend/unittest_http.rb @@ -11,7 +11,8 @@ class DNSBackendHandler < WEBrick::HTTPServlet::AbstractServlet def initialize(server, dnsbackend) @dnsbackend = dnsbackend @semaphore = Mutex.new - @f = File.open("/tmp/remotebackend.txt.#{$$}","a") + @f = File.open("/tmp/remotebackend.txt.#{$$}","ab") + @f.set_encoding 'UTF-8' end def parse_arrays(params) @@ -136,8 +137,11 @@ class DNSBackendHandler < WEBrick::HTTPServlet::AbstractServlet end args = parse_arrays args - - @f.puts "#{Time.now.to_f} [http]: #{({:method=>method,:parameters=>args}).to_json}" + begin + @f.puts "#{Time.now.to_f} [http]: #{({:method=>method,:parameters=>args}).to_json}" + rescue Encoding::UndefinedConversionError + # this fails with encoding error for feedEnts3 + end @semaphore.synchronize do if @dnsbackend.respond_to?(method.to_sym)