fix concurrency issue in AutowiredAttributeObjectPostProcessor where metada was left null if value was updated before lock was made

This commit is contained in:
Marko Lahma
2013-10-25 23:26:36 +03:00
parent 01b1f57224
commit 21cbbd0ac9

View File

@@ -21,7 +21,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
using System.Linq;
using Spring.Collections;
@@ -282,14 +281,13 @@ namespace Spring.Objects.Factory.Attributes
{
// Quick check on the concurrent map first, with minimal locking.
InjectionMetadata metadata = null;
if (_injectionMetadataCache.ContainsKey(objectType))
metadata = _injectionMetadataCache[objectType];
_injectionMetadataCache.TryGetValue(objectType, out metadata);
if (metadata == null)
{
lock (_injectionMetadataCache)
{
if (!_injectionMetadataCache.ContainsKey(objectType))
if (!_injectionMetadataCache.TryGetValue(objectType, out metadata))
{
metadata = BuildAutowiringMetadata(objectType);
_injectionMetadataCache.Add(objectType, metadata);