Method: NewRelic::Agent::Configuration::Manager#reset_cache

Defined in:
lib/new_relic/agent/configuration/manager.rb

#reset_cacheObject

reset the configuration hash, but do not replace previously auto determined dependency detection values with nil or ‘auto’

[View source]

397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
# File 'lib/new_relic/agent/configuration/manager.rb', line 397

def reset_cache
  return new_cache unless defined?(@cache) && @cache

  # Modifying the @cache hash under JRuby - even with a `synchronize do`
  # 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 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 }
  end

  @cache
end