codec/line: do charset conversion on flush

Add tests to verify line codec does charset conversion on flush.

Fixes #1520
This commit is contained in:
Jordan Sissel 2014-07-10 17:39:24 +00:00
parent 730363b269
commit c52bf786d6
2 changed files with 16 additions and 1 deletions

View file

@ -42,7 +42,7 @@ class LogStash::Codecs::Line < LogStash::Codecs::Base
def flush(&block) def flush(&block)
remainder = @buffer.flush remainder = @buffer.flush
if !remainder.empty? if !remainder.empty?
block.call(LogStash::Event.new({"message" => remainder})) block.call(LogStash::Event.new("message" => @converter.convert(remainder)))
end end
end end

View file

@ -48,4 +48,19 @@ describe LogStash::Codecs::Line do
end end
end end
end end
context "#flush" do
it "should convert charsets" do
garbage = [0xD0].pack("C")
subject.decode(garbage) do |e|
fail "Should not get here."
end
count = 0
subject.flush do |event|
count += 1
insist { event["message"].encoding } == Encoding::UTF_8
end
insist { count } == 1
end
end
end end