Skip to content

Commit 28205fc

Browse files
committed
CLeanup and make SessionFactoryImpl.identifierGenerators a ReadOnlyDictionary to line up with how collectionMetadata is built and improve determistic behavior under accidental multithreading
1 parent 9b9c3a1 commit 28205fc

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/NHibernate/Impl/SessionFactoryImpl.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ public void HandleEntityNotFound(string entityName, string propertyName, object
105105
new ConcurrentDictionary<string, CacheBase>();
106106

107107
[NonSerialized]
108-
private readonly IReadOnlyDictionary<string, IClassMetadata> classMetadata;
108+
private readonly IDictionary<string, IClassMetadata> classMetadata;
109109

110110
[NonSerialized]
111-
private readonly IReadOnlyDictionary<string, ICollectionMetadata> collectionMetadata;
111+
private readonly IDictionary<string, ICollectionMetadata> collectionMetadata;
112112
[NonSerialized]
113113
private readonly IReadOnlyDictionary<string, ICollectionPersister> collectionPersisters;
114114
[NonSerialized]
@@ -248,7 +248,7 @@ public SessionFactoryImpl(Configuration cfg, IMapping mapping, Settings settings
248248
#endregion
249249

250250
#region Generators
251-
identifierGenerators = new Dictionary<string, IIdentifierGenerator>();
251+
var tmpIdentifierGenerators = new Dictionary<string, IIdentifierGenerator>();
252252
foreach (PersistentClass model in cfg.ClassMappings)
253253
{
254254
if (!model.IsInherited)
@@ -257,9 +257,10 @@ public SessionFactoryImpl(Configuration cfg, IMapping mapping, Settings settings
257257
model.Identifier.CreateIdentifierGenerator(settings.Dialect, settings.DefaultCatalogName,
258258
settings.DefaultSchemaName, (RootClass)model);
259259

260-
identifierGenerators[model.EntityName] = generator;
260+
tmpIdentifierGenerators[model.EntityName] = generator;
261261
}
262262
}
263+
identifierGenerators = new ReadOnlyDictionary<string, IIdentifierGenerator>(tmpIdentifierGenerators);
263264
#endregion
264265

265266
#region Persisters

0 commit comments

Comments
 (0)