@SuppressWarnings("unchecked") public T get(HystrixConcurrencyStrategy concurrencyStrategy) { /* * 1) Fetch RequestVariable implementation from cache. * 2) If no implementation is found in cache then construct from factory. * 3) Cache implementation from factory as each object instance needs to be statically cached to be relevant across threads. */ RVCacheKey key = new RVCacheKey(this, concurrencyStrategy); HystrixRequestVariable<?> rvInstance = requestVariableInstance.get(key); if (rvInstance == null) { requestVariableInstance.putIfAbsent(key, concurrencyStrategy.getRequestVariable(lifeCycleMethods)); /* * A safety check to help debug problems if someone starts injecting dynamically created HystrixConcurrencyStrategy instances - which should not be done and has no good reason to be done. * * The 100 value is arbitrary ... just a number far higher than we should see. */ if (requestVariableInstance.size() > 100) { logger.warn("Over 100 instances of HystrixRequestVariable are being stored. This is likely the sign of a memory leak caused by using unique instances of HystrixConcurrencyStrategy instead of a single instance."); } } return (T) requestVariableInstance.get(key).get(); }
@SuppressWarnings("unchecked") public T get(HystrixConcurrencyStrategy concurrencyStrategy) { /* * 1) Fetch RequestVariable implementation from cache. * 2) If no implementation is found in cache then construct from factory. * 3) Cache implementation from factory as each object instance needs to be statically cached to be relevant across threads. */ RVCacheKey key = new RVCacheKey(this, concurrencyStrategy); HystrixRequestVariable<?> rvInstance = requestVariableInstance.get(key); if (rvInstance == null) { requestVariableInstance.putIfAbsent(key, concurrencyStrategy.getRequestVariable(lifeCycleMethods)); /* * A safety check to help debug problems if someone starts injecting dynamically created HystrixConcurrencyStrategy instances - which should not be done and has no good reason to be done. * * The 100 value is arbitrary ... just a number far higher than we should see. */ if (requestVariableInstance.size() > 100) { logger.warn("Over 100 instances of HystrixRequestVariable are being stored. This is likely the sign of a memory leak caused by using unique instances of HystrixConcurrencyStrategy instead of a single instance."); } } return (T) requestVariableInstance.get(key).get(); }