Skip to content

Commit 19d4549

Browse files
authored
Move persist tracking context out of the loop in AbstractFlushingEventListener (#3310)
Fixes #3307
1 parent 170210a commit 19d4549

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/NHibernate/Async/Event/Default/AbstractFlushingEventListener.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ protected virtual async Task PrepareEntityFlushesAsync(IEventSource session, Can
191191
cancellationToken.ThrowIfCancellationRequested();
192192
log.Debug("processing flush-time cascades");
193193

194+
var anything = Anything;
194195
ICollection list = IdentityMap.ConcurrentEntries(session.PersistenceContext.EntityEntries);
195196
//safe from concurrent modification because of how entryList() is implemented on IdentityMap
196197
foreach (DictionaryEntry me in list)
@@ -199,7 +200,7 @@ protected virtual async Task PrepareEntityFlushesAsync(IEventSource session, Can
199200
Status status = entry.Status;
200201
if (status == Status.Loaded || status == Status.Saving || status == Status.ReadOnly)
201202
{
202-
await (CascadeOnFlushAsync(session, entry.Persister, me.Key, Anything, cancellationToken)).ConfigureAwait(false);
203+
await (CascadeOnFlushAsync(session, entry.Persister, me.Key, anything, cancellationToken)).ConfigureAwait(false);
203204
}
204205
}
205206
}

src/NHibernate/Event/Default/AbstractFlushingEventListener.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ protected virtual void PrepareEntityFlushes(IEventSource session)
188188
{
189189
log.Debug("processing flush-time cascades");
190190

191+
var anything = Anything;
191192
ICollection list = IdentityMap.ConcurrentEntries(session.PersistenceContext.EntityEntries);
192193
//safe from concurrent modification because of how entryList() is implemented on IdentityMap
193194
foreach (DictionaryEntry me in list)
@@ -196,7 +197,7 @@ protected virtual void PrepareEntityFlushes(IEventSource session)
196197
Status status = entry.Status;
197198
if (status == Status.Loaded || status == Status.Saving || status == Status.ReadOnly)
198199
{
199-
CascadeOnFlush(session, entry.Persister, me.Key, Anything);
200+
CascadeOnFlush(session, entry.Persister, me.Key, anything);
200201
}
201202
}
202203
}

0 commit comments

Comments
 (0)