lib/new_relic/agent/configuration/manager.rb in newrelic_rpm-9.12.0 vs lib/new_relic/agent/configuration/manager.rb in newrelic_rpm-9.13.0
- old
+ new
@@ -380,9 +380,17 @@
# reset the configuration hash, but do not replace previously auto
# determined dependency detection values with nil or 'auto'
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 @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