Skip to content

Commit 41e5661

Browse files
committed
[Test] added test to verify that an error is correctly catched also when a conditional try to match against an invalid UTF-8 string
1 parent bcae14f commit 41e5661

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

logstash-core/spec/logstash/java_pipeline_spec.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,41 @@ def flush(options)
477477
expect(pipeline.last_error_evaluation_received).to match(/no implicit conversion of nil into Integer/)
478478
end
479479
end
480+
481+
describe "given a pipeline executing an event with invalid UTF-8 string" do
482+
let(:pipeline) do
483+
settings.set_value("queue.drain", true)
484+
LogStash::JavaPipeline.new(
485+
org.logstash.config.ir.PipelineConfig.new(
486+
LogStash::Config::Source::Local, :main,
487+
SourceWithMetadata.new(
488+
"config_string", "config_string",
489+
"input { spec_sampler_input {} }\n output { if [message] =~ /^(NOSQL|SQL):/ { spec_sampler_output {} } }"
490+
), settings
491+
)
492+
)
493+
end
494+
let(:event) do
495+
[LogStash::Event.new({ "message" => "abrac\xC5adabra"})]
496+
end
497+
498+
let(:results) do
499+
PipelineHelpers::SpecSamplerInput.set_event event
500+
pipeline.run
501+
PipelineHelpers::SpecSamplerOutput.seen
502+
end
503+
504+
after do
505+
pipeline.close
506+
end
507+
508+
subject {results.length > 1 ? results : results.first}
509+
510+
it "should raise an error without killing the pipeline" do
511+
expect(subject).to be nil
512+
expect(pipeline.last_error_evaluation_received).to match(/invalid byte sequence in UTF-8/)
513+
end
514+
end
480515
end
481516
end
482517
end

0 commit comments

Comments
 (0)