Skip to content

Commit

Permalink
Refactor BaseConnectionPool empty method
Browse files Browse the repository at this point in the history
Signed-off-by: Bandini Bhopi <bandinib@amazon.com>
  • Loading branch information
bandinib-amzn committed Aug 14, 2023
1 parent 9b44c61 commit 79efb7c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Bumps `eslint-config-prettier` from 8.8.0 to 9.0.0
### Changed
- Make handling of long numerals an option that is disabled by default ([#557](https://github.com/opensearch-project/opensearch-js/pull/557))
- Refactor BaseConnectionPool empty method so that callback will always get called even when there is no connection ([#585](https://github.com/opensearch-project/opensearch-js/pull/585))
### Deprecated
### Removed
### Fixed
Expand Down
11 changes: 6 additions & 5 deletions lib/pool/BaseConnectionPool.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,14 @@ class BaseConnectionPool {
let openConnections = this.size;
this.connections.forEach((connection) => {
connection.close(() => {
if (--openConnections === 0) {
this.connections = [];
this.size = this.connections.length;
callback();
}
openConnections--;
});
});
if (openConnections === 0) {
this.connections = [];
this.size = this.connections.length;
callback();
}
}

/**
Expand Down

0 comments on commit 79efb7c

Please sign in to comment.