Skip to content

Commit a98965e

Browse files
committed
fixed webcontrol object naming compatibility issue
fixed factory product caching
1 parent 4c56756 commit a98965e

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/Spring/Spring.Core/Objects/Factory/Support/AbstractObjectFactory.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -836,22 +836,23 @@ protected internal virtual object GetObjectForInstance(object instance, string n
836836

837837
if (factory.IsSingleton && ContainsSingleton(canonicalName))
838838
{
839-
lock (factoryObjectProductCache)
839+
lock (factoryObjectProductCache.SyncRoot)
840840
{
841841
resultInstance = factoryObjectProductCache[canonicalName];
842842
if (resultInstance == null)
843843
{
844844
resultInstance = GetObjectFromFactoryObject(factory, canonicalName, rod);
845845
if (resultInstance != null)
846846
{
847-
factoryObjectProductCache.Add(canonicalName, resultInstance);
847+
factoryObjectProductCache[canonicalName] = resultInstance;
848848
}
849-
return resultInstance;
850849
}
851850
}
852851
}
853-
854-
resultInstance = GetObjectFromFactoryObject(factory, canonicalName, rod);
852+
else
853+
{
854+
resultInstance = GetObjectFromFactoryObject(factory, canonicalName, rod);
855+
}
855856

856857
if (resultInstance == null)
857858
{

src/Spring/Spring.Web/Objects/Factory/Xml/WebObjectDefinitionParserHelper.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected override string PostProcessObjectNameAndAliases(string objectName, Sys
5858
objectName = webObjectNameGenerator.CreatePageDefinitionName(url);
5959
}
6060

61-
// adjust aliases if necessary
61+
// strip leading homepath symbol ('~') from aliases if necessary
6262
for (int ai = 0; ai < aliases.Count; ai++)
6363
{
6464
string alias = (string)aliases[ai];
@@ -70,9 +70,14 @@ protected override string PostProcessObjectNameAndAliases(string objectName, Sys
7070
}
7171
else if (strTypeName.EndsWith(".ascx") || strTypeName.EndsWith(".master"))
7272
{
73+
string controlName = webObjectNameGenerator.CreateControlDefinitionName(url);
7374
if (!StringUtils.HasText(objectName))
7475
{
75-
objectName = webObjectNameGenerator.CreateControlDefinitionName(url);
76+
objectName = controlName;
77+
}
78+
else
79+
{
80+
aliases.Add(controlName);
7681
}
7782
}
7883

0 commit comments

Comments
 (0)