lib/new_relic/agent/configuration/manager.rb in newrelic_rpm-9.13.0 vs lib/new_relic/agent/configuration/manager.rb in newrelic_rpm-9.14.0
- old
+ new
@@ -140,10 +140,13 @@
def evaluate_and_apply_transformations(key, value)
evaluated = evaluate_procs(value)
default = enforce_allowlist(key, evaluated)
return default if default
+ boolean = enforce_boolean(key, value)
+ return boolean if [true, false].include?(boolean)
+
apply_transformations(key, evaluated)
end
def apply_transformations(key, value)
if transform = transform_from_default(key)
@@ -165,10 +168,22 @@
default = default_source.default_for(key)
NewRelic::Agent.logger.warn "Invalid value '#{value}' for #{key}, applying default value of '#{default}'"
default
end
+ def enforce_boolean(key, value)
+ type = default_source.value_from_defaults(key, :type)
+ return unless type == Boolean
+
+ bool_value = default_source.boolean_for(key, value)
+ return bool_value unless bool_value.nil?
+
+ default = default_source.default_for(key)
+ NewRelic::Agent.logger.warn "Invalid value '#{value}' for #{key}, applying default value of '#{default}'"
+ default
+ end
+
def transform_from_default(key)
default_source.transform_for(key)
end
def default_source
@@ -386,10 +401,10 @@
# block and a `Hash#dup` operation - has been known to cause issues
# with JRuby for concurrent access of the hash while it is being
# modified. The hash really only needs to be modified for the benefit
# of the security agent, so if JRuby is in play and the security agent
# is not, don't attempt to modify the hash at all and return early.
- return @cache if NewRelic::LanguageSupport.jruby? && !Agent.config[:'security.agent.enabled']
+ return new_cache if NewRelic::LanguageSupport.jruby? && !Agent.config[:'security.agent.enabled']
@lock.synchronize do
preserved = @cache.dup.select { |_k, v| DEPENDENCY_DETECTION_VALUES.include?(v) }
new_cache
preserved.each { |k, v| @cache[k] = v }