File tree Expand file tree Collapse file tree 5 files changed +13
-45
lines changed Expand file tree Collapse file tree 5 files changed +13
-45
lines changed Original file line number Diff line number Diff line change @@ -70,8 +70,7 @@ export default class ConnectionHolder {
7070
7171 this . _referenceCount -- ;
7272 if ( this . _referenceCount === 0 ) {
73- // release a connection without muting ACK_FAILURE, this is the last action on this connection
74- return this . _releaseConnection ( true ) ;
73+ return this . _releaseConnection ( ) ;
7574 }
7675 return this . _connectionPromise ;
7776 }
@@ -85,9 +84,7 @@ export default class ConnectionHolder {
8584 return this . _connectionPromise ;
8685 }
8786 this . _referenceCount = 0 ;
88- // release a connection and mute ACK_FAILURE, this might be called concurrently with other
89- // operations and thus should ignore failure handling
90- return this . _releaseConnection ( false ) ;
87+ return this . _releaseConnection ( ) ;
9188 }
9289
9390 /**
@@ -97,14 +94,10 @@ export default class ConnectionHolder {
9794 * @return {Promise } - promise resolved then connection is returned to the pool.
9895 * @private
9996 */
100- _releaseConnection ( sync ) {
97+ _releaseConnection ( ) {
10198 this . _connectionPromise = this . _connectionPromise . then ( connection => {
10299 if ( connection ) {
103- if ( sync ) {
104- connection . reset ( ) ;
105- } else {
106- connection . resetAsync ( ) ;
107- }
100+ connection . reset ( ) ;
108101 connection . sync ( ) ;
109102 connection . _release ( ) ;
110103 }
Original file line number Diff line number Diff line change @@ -315,8 +315,8 @@ class Connection {
315315 }
316316
317317 /** Queue a RESET-message to be sent to the database. Mutes failure handling. */
318- resetAsync ( observer ) {
319- log ( "C" , "RESET_ASYNC" ) ;
318+ reset ( observer ) {
319+ log ( 'C' , 'RESET' ) ;
320320 this . _isHandlingFailure = true ;
321321 let self = this ;
322322 let wrappedObs = {
@@ -330,14 +330,6 @@ class Connection {
330330 }
331331 } ;
332332 this . _queueObserver ( wrappedObs ) ;
333- this . _packer . packStruct ( RESET , [ ] , ( err ) => this . _handleFatalError ( err ) ) ;
334- this . _chunker . messageBoundary ( ) ;
335- }
336-
337- /** Queue a RESET-message to be sent to the database */
338- reset ( observer ) {
339- log ( 'C' , 'RESET' ) ;
340- this . _queueObserver ( observer ) ;
341333 this . _packer . packStruct ( RESET , [ ] , ( err ) => this . _handleFatalError ( err ) ) ;
342334 this . _chunker . messageBoundary ( ) ;
343335 }
Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ describe('ConnectionHolder', () => {
168168 connectionHolder . initializeConnection ( ) ;
169169
170170 connectionHolder . close ( ) . then ( ( ) => {
171- expect ( connection . isReleasedOnceOnSessionClose ( ) ) . toBeTruthy ( ) ;
171+ expect ( connection . isReleasedOnce ( ) ) . toBeTruthy ( ) ;
172172 done ( ) ;
173173 } ) ;
174174 } ) ;
@@ -201,11 +201,11 @@ describe('ConnectionHolder', () => {
201201 connectionHolder . initializeConnection ( ) ;
202202
203203 connectionHolder . close ( ) . then ( ( ) => {
204- expect ( connection1 . isReleasedOnceOnSessionClose ( ) ) . toBeTruthy ( ) ;
204+ expect ( connection1 . isReleasedOnce ( ) ) . toBeTruthy ( ) ;
205205
206206 connectionHolder . initializeConnection ( ) ;
207207 connectionHolder . close ( ) . then ( ( ) => {
208- expect ( connection2 . isReleasedOnceOnSessionClose ( ) ) . toBeTruthy ( ) ;
208+ expect ( connection2 . isReleasedOnce ( ) ) . toBeTruthy ( ) ;
209209 done ( ) ;
210210 } ) ;
211211 } ) ;
Original file line number Diff line number Diff line change @@ -31,7 +31,6 @@ export default class FakeConnection {
3131 this . creationTimestamp = Date . now ( ) ;
3232
3333 this . resetInvoked = 0 ;
34- this . resetAsyncInvoked = 0 ;
3534 this . syncInvoked = 0 ;
3635 this . releaseInvoked = 0 ;
3736 this . initializationInvoked = 0 ;
@@ -54,10 +53,6 @@ export default class FakeConnection {
5453 this . resetInvoked ++ ;
5554 }
5655
57- resetAsync ( ) {
58- this . resetAsyncInvoked ++ ;
59- }
60-
6156 sync ( ) {
6257 this . syncInvoked ++ ;
6358 }
@@ -75,17 +70,6 @@ export default class FakeConnection {
7570 return this . _open ;
7671 }
7772
78- isReleasedOnceOnSessionClose ( ) {
79- return this . isReleasedOnSessionCloseTimes ( 1 ) ;
80- }
81-
82- isReleasedOnSessionCloseTimes ( times ) {
83- return this . resetAsyncInvoked === times &&
84- this . resetInvoked === 0 &&
85- this . syncInvoked === times &&
86- this . releaseInvoked === times ;
87- }
88-
8973 isNeverReleased ( ) {
9074 return this . isReleasedTimes ( 0 ) ;
9175 }
@@ -95,8 +79,7 @@ export default class FakeConnection {
9579 }
9680
9781 isReleasedTimes ( times ) {
98- return this . resetAsyncInvoked === 0 &&
99- this . resetInvoked === times &&
82+ return this . resetInvoked === times &&
10083 this . syncInvoked === times &&
10184 this . releaseInvoked === times ;
10285 }
Original file line number Diff line number Diff line change @@ -77,13 +77,13 @@ describe('session', () => {
7777 const session = newSessionWithConnection ( connection ) ;
7878
7979 session . close ( ( ) => {
80- expect ( connection . isReleasedOnceOnSessionClose ( ) ) . toBeTruthy ( ) ;
80+ expect ( connection . isReleasedOnce ( ) ) . toBeTruthy ( ) ;
8181
8282 session . close ( ( ) => {
83- expect ( connection . isReleasedOnceOnSessionClose ( ) ) . toBeTruthy ( ) ;
83+ expect ( connection . isReleasedOnce ( ) ) . toBeTruthy ( ) ;
8484
8585 session . close ( ( ) => {
86- expect ( connection . isReleasedOnceOnSessionClose ( ) ) . toBeTruthy ( ) ;
86+ expect ( connection . isReleasedOnce ( ) ) . toBeTruthy ( ) ;
8787 done ( ) ;
8888 } ) ;
8989 } ) ;
You can’t perform that action at this time.
0 commit comments