@@ -97,7 +97,8 @@ public void TestStreamAdapter()
9797 Enforcer e = new ( "Examples/basic_model.conf" ) ;
9898 Assert . False ( e . Enforce ( "alice" , "data1" , "read" ) ) ;
9999
100- StreamAdapter a = new ( File . OpenRead ( "Examples/basic_policy.csv" ) ) ;
100+ using FileStream stream = File . OpenRead ( "Examples/basic_policy.csv" ) ;
101+ StreamAdapter a = new ( stream ) ;
101102 e . SetAdapter ( a ) ;
102103 e . LoadPolicy ( ) ;
103104
@@ -117,7 +118,8 @@ public async Task TestStreamAdapterAsync()
117118 Enforcer e = new ( "Examples/basic_model.conf" ) ;
118119 Assert . False ( await e . EnforceAsync ( "alice" , "data1" , "read" ) ) ;
119120
120- StreamAdapter a = new ( File . OpenRead ( "Examples/basic_policy.csv" ) ) ;
121+ using FileStream stream = File . OpenRead ( "Examples/basic_policy.csv" ) ;
122+ StreamAdapter a = new ( stream ) ;
121123 e . SetAdapter ( a ) ;
122124 await e . LoadPolicyAsync ( ) ;
123125
@@ -137,7 +139,8 @@ public void TestFilteredStreamAdapter()
137139 Enforcer e = new ( "Examples/basic_model.conf" ) ;
138140 Assert . False ( e . Enforce ( "alice" , "data1" , "read" ) ) ;
139141
140- StreamAdapter a = new ( File . OpenRead ( "Examples/basic_policy.csv" ) ) ;
142+ using FileStream stream = File . OpenRead ( "Examples/basic_policy.csv" ) ;
143+ StreamAdapter a = new ( stream ) ;
141144 e . SetAdapter ( a ) ;
142145 e . LoadFilteredPolicy ( new PolicyFilter ( PermConstants . DefaultPolicyType , 0 , Policy . ValuesFrom ( [ "bob" ] ) ) ) ;
143146
@@ -157,7 +160,8 @@ public async Task TestFilteredStreamAdapterAsync()
157160 Enforcer e = new ( "Examples/basic_model.conf" ) ;
158161 Assert . False ( await e . EnforceAsync ( "alice" , "data1" , "read" ) ) ;
159162
160- StreamAdapter a = new ( File . OpenRead ( "Examples/basic_policy.csv" ) ) ;
163+ using FileStream stream = File . OpenRead ( "Examples/basic_policy.csv" ) ;
164+ StreamAdapter a = new ( stream ) ;
161165 e . SetAdapter ( a ) ;
162166 await e . LoadFilteredPolicyAsync ( new PolicyFilter ( PermConstants . DefaultPolicyType , 0 , Policy . ValuesFrom ( [ "bob" ] ) ) ) ;
163167
0 commit comments