File tree Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -359,8 +359,11 @@ public void CloseReader(DbDataReader reader)
359359 var actualReader = rsw == null ? reader : rsw . Target ;
360360 _readersToClose . Remove ( actualReader ) ;
361361
362+ var duration = GetReaderStopwatch ( actualReader ) ;
363+
362364 try
363365 {
366+ //TODO: Shouldn't we close reader instead?
364367 reader . Dispose ( ) ;
365368 }
366369 catch ( Exception e )
@@ -370,17 +373,24 @@ public void CloseReader(DbDataReader reader)
370373 }
371374
372375 LogCloseReader ( ) ;
376+ LogDuration ( duration ) ;
377+ }
373378
374- if ( ! Log . IsDebugEnabled )
375- return ;
376-
377- var nhReader = actualReader as NHybridDataReader ;
378- actualReader = nhReader == null ? actualReader : nhReader . Target ;
379+ private Stopwatch GetReaderStopwatch ( DbDataReader reader )
380+ {
381+ var nhReader = reader as NHybridDataReader ;
382+ var actualReader = nhReader == null ? reader : nhReader . Target ;
379383
380384 Stopwatch duration ;
381- if ( _readersDuration . TryGetValue ( actualReader , out duration ) == false )
382- return ;
383- _readersDuration . Remove ( actualReader ) ;
385+ if ( _readersDuration . TryGetValue ( actualReader , out duration ) )
386+ _readersDuration . Remove ( actualReader ) ;
387+ return duration ;
388+ }
389+
390+ private static void LogDuration ( Stopwatch duration )
391+ {
392+ if ( ! Log . IsDebugEnabled || duration == null ) return ;
393+
384394 Log . DebugFormat ( "DataReader was closed after {0} ms" , duration . ElapsedMilliseconds ) ;
385395 }
386396
You can’t perform that action at this time.
0 commit comments