@@ -20,11 +20,14 @@ module.exports = function () {
2020 } ) ;
2121
2222 this . Then ( / ^ s e s s i o n s s h o u l d s i m p l y w o r k $ / , { timeout : CALLBACK_TIMEOUT } , function ( callback ) {
23- var session = this . driver1 . session ( ) ;
23+ var self = this ;
24+ var session = self . driver1 . session ( ) ;
2425 session . run ( "RETURN 1" ) . then ( function ( result ) {
2526 session . close ( ) ;
27+ _closeDrivers ( self . driver1 , self . driver2 ) ;
2628 callback ( ) ;
2729 } ) . catch ( function ( error ) {
30+ _closeDrivers ( self . driver1 , self . driver2 ) ;
2831 console . log ( error ) ;
2932 } ) ;
3033 } ) ;
@@ -57,11 +60,13 @@ module.exports = function () {
5760 var self = this ;
5861 session . run ( "RETURN 1" )
5962 . then ( function ( res ) {
63+ _closeDrivers ( self . driver1 , self . driver2 ) ;
6064 console . log ( res ) ;
6165 } )
6266 . catch ( function ( error ) {
6367 self . error = error ;
6468 session . close ( ) ;
69+ _closeDrivers ( self . driver1 , self . driver2 ) ;
6570 callback ( ) ;
6671 } ) ;
6772 } ) ;
@@ -76,6 +81,9 @@ module.exports = function () {
7681 "and the driver will update the file with the new certificate. You can configure which file the driver should use " +
7782 "to store this information by setting `knownHosts` to another path in your driver configuration - " +
7883 "and you can disable encryption there as well using `encrypted:\"ENCRYPTION_OFF\"`." ;
84+
85+ _closeDrivers ( this . driver1 , this . driver2 ) ;
86+
7987 if ( this . error . message !== expected ) {
8088 callback ( new Error ( "Given and expected results does not match: " + this . error . message + " Expected " + expected ) ) ;
8189 } else {
@@ -101,6 +109,7 @@ module.exports = function () {
101109 var session2 = self . driver2 . session ( ) ;
102110 session2 . run ( "RETURN 1" ) . then ( function ( result ) {
103111 session2 . close ( ) ;
112+ _closeDrivers ( self . driver1 , self . driver2 ) ;
104113 callback ( ) ;
105114 } ) ;
106115 } ) ;
@@ -157,6 +166,9 @@ module.exports = function () {
157166 "`neo4j.v1.driver(.., { trustedCertificates:['path/to/certificate.crt']}). This is a security measure to protect " +
158167 "against man-in-the-middle attacks. If you are just trying Neo4j out and are not concerned about encryption, " +
159168 "simply disable it using `encrypted=\"ENCRYPTION_OFF\"` in the driver options. Socket responded with: DEPTH_ZERO_SELF_SIGNED_CERT" ;
169+
170+ _closeDrivers ( this . driver1 , this . driver2 ) ;
171+
160172 if ( this . error . message !== expected ) {
161173 callback ( new Error ( "Given and expected results does not match: " + this . error . message + " Expected " + expected ) ) ;
162174 } else {
@@ -171,4 +183,13 @@ module.exports = function () {
171183 encrypted : "ENCRYPTION_ON"
172184 } ) ;
173185 }
186+
187+ function _closeDrivers ( ) {
188+ for ( var i = 0 ; i < arguments . length ; i ++ ) {
189+ var driver = arguments [ i ] ;
190+ if ( driver ) {
191+ driver . close ( ) ;
192+ }
193+ }
194+ }
174195} ;
0 commit comments