@@ -8,32 +8,30 @@ namespace NHibernate.Test.Linq
8
8
{
9
9
public class ExpressionSessionLeakTest : LinqTestCase
10
10
{
11
- [ Test ]
12
- [ Ignore ( "Not fixed yet. NH-3579" ) ]
11
+ [ Test , KnownBug ( "NH-3579" ) ]
13
12
public void SessionGetsCollected ( )
14
13
{
15
14
var reference = DoLinqInSeparateSession ( ) ;
16
15
17
16
GC . Collect ( ) ;
18
17
19
- Assert . Null ( reference . Target ) ;
18
+ Assert . That ( reference . IsAlive , Is . False ) ;
20
19
}
21
20
22
-
23
21
private WeakReference DoLinqInSeparateSession ( )
24
22
{
25
- var leakTest = session . SessionFactory . OpenSession ( ) ;
26
-
27
- // It appears linq expressions will (or might) contain a reference to the
28
- // IQueryable. At time of writing, linq expressions are helt within NhLinqExpression,
29
- // which in turn will be held in the query plan cache. Since the IQueryable will
30
- // be an NhQueryable, which holds a reference to the SessionImpl instance,
31
- // we will be leaking session instances.
32
-
33
- var query = leakTest . Query < Customer > ( ) . FirstOrDefault ( t => t . CustomerId != "" ) ;
34
- leakTest . Dispose ( ) ;
35
-
36
- return new WeakReference ( leakTest , false ) ;
23
+ using ( var leakTest = session . SessionFactory . OpenSession ( ) )
24
+ {
25
+ // It appears linq expressions will (or might) contain a reference to the
26
+ // IQueryable. At time of writing, linq expressions are helt within NhLinqExpression,
27
+ // which in turn will be held in the query plan cache. Since the IQueryable will
28
+ // be an NhQueryable, which holds a reference to the SessionImpl instance,
29
+ // we will be leaking session instances.
30
+
31
+ var query = leakTest . Query < Customer > ( ) . FirstOrDefault ( t => t . CustomerId != "" ) ;
32
+
33
+ return new WeakReference ( leakTest , false ) ;
34
+ }
37
35
}
38
36
}
39
37
}
0 commit comments