Skip to content

Commit

Permalink
fix: route all config of stream read constraints through ObjectMappers
Browse files Browse the repository at this point in the history
  • Loading branch information
yaauie committed Dec 4, 2024
1 parent 4f09282 commit 37bf0a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions logstash-core/lib/logstash/util/jackson.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ module Util
module Jackson

def self.verify_jackson_overrides
java_import org.logstash.jackson.StreamReadConstraintsUtil
java_import org.logstash.ObjectMappers

StreamReadConstraintsUtil.fromSystemProperties().validateIsGlobalDefault()
ObjectMappers.getConfiguredStreamReadConstraints().validateIsGlobalDefault()
end

end
Expand Down
14 changes: 12 additions & 2 deletions logstash-core/src/main/java/org/logstash/ObjectMappers.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,21 @@

public final class ObjectMappers {

static final String RUBY_SERIALIZERS_MODULE_ID = "RubySerializers";

static final StreamReadConstraintsUtil CONFIGURED_STREAM_READ_CONSTRAINTS;

static {
StreamReadConstraintsUtil.fromSystemProperties().applyAsGlobalDefault();
// The StreamReadConstraintsUtil needs to load the configured constraints from system
// properties and apply them _statically_, before any object mappers are initialized.
CONFIGURED_STREAM_READ_CONSTRAINTS = StreamReadConstraintsUtil.fromSystemProperties();
CONFIGURED_STREAM_READ_CONSTRAINTS.applyAsGlobalDefault();
}

static StreamReadConstraintsUtil getConfiguredStreamReadConstraints() {
return CONFIGURED_STREAM_READ_CONSTRAINTS;
}

static final String RUBY_SERIALIZERS_MODULE_ID = "RubySerializers";

private static final SimpleModule RUBY_SERIALIZERS =
new SimpleModule(RUBY_SERIALIZERS_MODULE_ID)
Expand Down

0 comments on commit 37bf0a4

Please sign in to comment.