Skip to content

Commit abbb054

Browse files
committed
Make connection.close() the primary method in the code, not just in the documentation
1 parent 7c30aaf commit abbb054

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

lib/connection.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var executePromisified;
2626
var commitPromisified;
2727
var createLobPromisified;
2828
var rollbackPromisified;
29-
var releasePromisified;
29+
var closePromisified;
3030
var breakPromisified;
3131
var changePasswordPromisified;
3232

@@ -218,26 +218,26 @@ function rollback(rollbackCb) {
218218

219219
rollbackPromisified = nodbUtil.promisify(rollback);
220220

221-
// This release function is used to override the release method of the Connection
221+
// This close function is used to override the close method of the Connection
222222
// class, which is defined in the C layer.
223-
function release(releaseCb) {
223+
function close(closeCb) {
224224
var self = this;
225225

226226
nodbUtil.assert(arguments.length === 1, 'NJS-009');
227-
nodbUtil.assert(typeof releaseCb === 'function', 'NJS-006', 1);
227+
nodbUtil.assert(typeof closeCb === 'function', 'NJS-006', 1);
228228

229-
self._release(function(err) {
229+
self._close(function(err) {
230230
if (!err) {
231231
self.emit('_after_close');
232232
}
233233

234-
releaseCb(err);
234+
closeCb(err);
235235
});
236236
}
237237

238-
releasePromisified = nodbUtil.promisify(release);
238+
closePromisified = nodbUtil.promisify(close);
239239

240-
// This release function is just a place holder to allow for easier extension later.
240+
// This break function is just a place holder to allow for easier extension later.
241241
// It's attached to the module as break is a reserved word.
242242
module.break = function(breakCb) {
243243
var self = this;
@@ -319,16 +319,16 @@ function extend(conn, oracledb, pool) {
319319
enumerable: true,
320320
writable: true
321321
},
322-
_release: {
323-
value: conn.release
322+
_close: {
323+
value: conn.close
324324
},
325-
release: {
326-
value: releasePromisified,
325+
close: {
326+
value: closePromisified,
327327
enumerable: true,
328328
writable: true
329329
},
330-
close: { // alias for release
331-
value: releasePromisified,
330+
release: { // alias for close
331+
value: closePromisified,
332332
enumerable: true,
333333
writable: true
334334
},

src/njsConnection.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void njsConnection::Init(Handle<Object> target)
8080
tpl->SetClassName(Nan::New<v8::String>("Connection").ToLocalChecked());
8181

8282
Nan::SetPrototypeMethod(tpl, "execute", Execute);
83-
Nan::SetPrototypeMethod(tpl, "release", Release);
83+
Nan::SetPrototypeMethod(tpl, "close", Close);
8484
Nan::SetPrototypeMethod(tpl, "commit", Commit);
8585
Nan::SetPrototypeMethod(tpl, "rollback", Rollback);
8686
Nan::SetPrototypeMethod(tpl, "break", Break);
@@ -1481,7 +1481,7 @@ void njsConnection::Async_AfterExecute(njsBaton *baton, Local<Value> argv[])
14811481

14821482

14831483
//-----------------------------------------------------------------------------
1484-
// njsConnection::Release()
1484+
// njsConnection::Close()
14851485
// Releases the connection from use by JS. This releases the connection back
14861486
// to the pool or closes the standalone connection so further use is not
14871487
// possible. The reference to the DPI handle is transferred to the baton so
@@ -1491,7 +1491,7 @@ void njsConnection::Async_AfterExecute(njsBaton *baton, Local<Value> argv[])
14911491
// PARAMETERS
14921492
// - JS callback which will receive (error)
14931493
//-----------------------------------------------------------------------------
1494-
NAN_METHOD(njsConnection::Release)
1494+
NAN_METHOD(njsConnection::Close)
14951495
{
14961496
njsConnection *connection;
14971497
njsBaton *baton;
@@ -1504,17 +1504,17 @@ NAN_METHOD(njsConnection::Release)
15041504
return;
15051505
baton->dpiConnHandle = connection->dpiConnHandle;
15061506
connection->dpiConnHandle = NULL;
1507-
baton->QueueWork("Release", Async_Release, NULL, 1);
1507+
baton->QueueWork("Close", Async_Close, NULL, 1);
15081508
}
15091509

15101510

15111511
//-----------------------------------------------------------------------------
1512-
// njsConnection::Async_Release()
1513-
// Worker function for njsConnection::Release() method. If the attempt to
1512+
// njsConnection::Async_Close()
1513+
// Worker function for njsConnection::Close() method. If the attempt to
15141514
// close fails, the reference to the DPI handle is transferred back from the
15151515
// baton to the connection.
15161516
//-----------------------------------------------------------------------------
1517-
void njsConnection::Async_Release(njsBaton *baton)
1517+
void njsConnection::Async_Close(njsBaton *baton)
15181518
{
15191519
if (dpiConn_close(baton->dpiConnHandle, DPI_MODE_CONN_CLOSE_DEFAULT, NULL,
15201520
0) < 0) {
@@ -1527,10 +1527,10 @@ void njsConnection::Async_Release(njsBaton *baton)
15271527

15281528

15291529
//-----------------------------------------------------------------------------
1530-
// njsConnection::Async_AfterRelease()
1531-
// Finishes release by cleaning up references.
1530+
// njsConnection::Async_AfterClose()
1531+
// Finishes close by cleaning up references.
15321532
//-----------------------------------------------------------------------------
1533-
void njsConnection::Async_AfterRelease(njsBaton *baton, Local<Value> argv[])
1533+
void njsConnection::Async_AfterClose(njsBaton *baton, Local<Value> argv[])
15341534
{
15351535
njsConnection *connection = (njsConnection*) baton->callingObj;
15361536
connection->jsOracledb.Reset();

src/njsConnection.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ class njsConnection: public njsCommon {
9898
static void Async_Execute(njsBaton *baton);
9999
static void Async_AfterExecute(njsBaton *baton, Local<Value> argv[]);
100100

101-
// Release Method on Connection class
102-
static NAN_METHOD(Release);
103-
static void Async_Release(njsBaton *baton);
104-
static void Async_AfterRelease(njsBaton *baton, Local<Value> argv[]);
101+
// Close Method on Connection class
102+
static NAN_METHOD(Close);
103+
static void Async_Close(njsBaton *baton);
104+
static void Async_AfterClose(njsBaton *baton, Local<Value> argv[]);
105105

106106
// Commit Method on Connection class
107107
static NAN_METHOD(Commit);

0 commit comments

Comments
 (0)