mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
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:
parent
730363b269
commit
c52bf786d6
2 changed files with 16 additions and 1 deletions
|
@ -42,7 +42,7 @@ class LogStash::Codecs::Line < LogStash::Codecs::Base
|
|||
def flush(&block)
|
||||
remainder = @buffer.flush
|
||||
if !remainder.empty?
|
||||
block.call(LogStash::Event.new({"message" => remainder}))
|
||||
block.call(LogStash::Event.new("message" => @converter.convert(remainder)))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -48,4 +48,19 @@ describe LogStash::Codecs::Line do
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue