Skip to content

Commit 4e2458c

Browse files
committed
Make SessionFactoryObjectFactory safe to use in a threaded environment. Avoid situations where the IDictionary<string, ISessionFactory>'s can be messed up from readers and writers interacting with them at the same time
1 parent f5a7a1f commit 4e2458c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/NHibernate/Impl/SessionFactoryObjectFactory.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Collections.Concurrent;
12
using System.Collections.Generic;
23
using System.Runtime.CompilerServices;
34

@@ -21,8 +22,8 @@ public static class SessionFactoryObjectFactory
2122
{
2223
private static readonly INHibernateLogger log;
2324

24-
private static readonly IDictionary<string, ISessionFactory> Instances = new Dictionary<string, ISessionFactory>();
25-
private static readonly IDictionary<string, ISessionFactory> NamedInstances = new Dictionary<string, ISessionFactory>();
25+
private static readonly IDictionary<string, ISessionFactory> Instances = new ConcurrentDictionary<string, ISessionFactory>();
26+
private static readonly IDictionary<string, ISessionFactory> NamedInstances = new ConcurrentDictionary<string, ISessionFactory>();
2627

2728
/// <summary></summary>
2829
static SessionFactoryObjectFactory()

0 commit comments

Comments
 (0)