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 @@ -358,8 +358,11 @@ public void CloseReader(IDataReader reader)
358
358
var actualReader = rsw == null ? reader : rsw . Target ;
359
359
_readersToClose . Remove ( actualReader ) ;
360
360
361
+ var duration = GetReaderStopwatch ( actualReader ) ;
362
+
361
363
try
362
364
{
365
+ //TODO: Shouldn't we close reader instead?
363
366
reader . Dispose ( ) ;
364
367
}
365
368
catch ( Exception e )
@@ -369,17 +372,24 @@ public void CloseReader(IDataReader reader)
369
372
}
370
373
371
374
LogCloseReader ( ) ;
375
+ LogDuration ( duration ) ;
376
+ }
372
377
373
- if ( ! Log . IsDebugEnabled )
374
- return ;
375
-
376
- var nhReader = actualReader as NHybridDataReader ;
377
- actualReader = nhReader == null ? actualReader : nhReader . Target ;
378
+ private Stopwatch GetReaderStopwatch ( DbDataReader reader )
379
+ {
380
+ var nhReader = reader as NHybridDataReader ;
381
+ var actualReader = nhReader == null ? reader : nhReader . Target ;
378
382
379
383
Stopwatch duration ;
380
- if ( _readersDuration . TryGetValue ( actualReader , out duration ) == false )
381
- return ;
382
- _readersDuration . Remove ( actualReader ) ;
384
+ if ( _readersDuration . TryGetValue ( actualReader , out duration ) )
385
+ _readersDuration . Remove ( actualReader ) ;
386
+ return duration ;
387
+ }
388
+
389
+ private static void LogDuration ( Stopwatch duration )
390
+ {
391
+ if ( ! Log . IsDebugEnabled || duration == null ) return ;
392
+
383
393
Log . DebugFormat ( "DataReader was closed after {0} ms" , duration . ElapsedMilliseconds ) ;
384
394
}
385
395
You can’t perform that action at this time.
0 commit comments