From cd01e54a8230025441cbe1a3e05c116596ec8b75 Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Thu, 6 Feb 2014 13:30:06 +0200 Subject: [PATCH] Catch conversion error and ignore it for logging --- modules/remotebackend/unittest_http.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/remotebackend/unittest_http.rb b/modules/remotebackend/unittest_http.rb index e4a579ec1d..1a304d0405 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) -- 2.47.2