Skip to content

Commit 1104149

Browse files
committed
Add the correct pool reconfiguration error messages
1 parent c2feec0 commit 1104149

File tree

5 files changed

+34
-7
lines changed

5 files changed

+34
-7
lines changed

doc/src/release_notes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ Common Changes
2323
#) Added support for an Oracle Database 23c JSON feature improving JSON
2424
storage usage.
2525

26+
#) Updated error thrown during pool reconfiguration while poolMax is 0 from
27+
`ORA-24413` to `NJS-007`.
28+
29+
#) Added new condition check during pool reconfiguration for `poolMin > poolMax`
30+
and error `NJS-092` will be thrown.
31+
2632
Thin Mode Changes
2733
++++++++++++++++++
2834

lib/connection.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -570,11 +570,8 @@ class Connection extends EventEmitter {
570570
} else {
571571

572572
// fetchArraySize must be a positive integer
573-
if (options.fetchArraySize !== undefined) {
574-
errors.assertParamPropValue(Number.isInteger(options.fetchArraySize) &&
575-
options.fetchArraySize > 0, 3, "fetchArraySize");
576-
outOptions.fetchArraySize = options.fetchArraySize;
577-
}
573+
errors.assertParamPropUnsignedIntNonZero(options, 3, "fetchArraySize");
574+
outOptions.fetchArraySize = options.fetchArraySize;
578575

579576
// fetchInfo must be an object with keys containing an object with a
580577
// "type" property; these are converted to an array of objects for ease

lib/errors.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,19 @@ function assertParamPropUnsignedInt(obj, parameterNum, propName) {
549549
}
550550
}
551551

552+
//-----------------------------------------------------------------------------
553+
// assertParamPropUnsignedIntNonZero()
554+
//
555+
// Asserts that the property value of a parameter is a positive integer value
556+
// (or undefined).
557+
//-----------------------------------------------------------------------------
558+
function assertParamPropUnsignedIntNonZero(obj, parameterNum, propName) {
559+
if (obj[propName] !== undefined) {
560+
assertParamPropValue(Number.isInteger(obj[propName]) && obj[propName] > 0,
561+
parameterNum, propName);
562+
}
563+
}
564+
552565
//-----------------------------------------------------------------------------
553566
// assertParamPropString()
554567
//
@@ -825,6 +838,7 @@ module.exports = {
825838
assertParamPropInt,
826839
assertParamPropString,
827840
assertParamPropUnsignedInt,
841+
assertParamPropUnsignedIntNonZero,
828842
assertParamPropValue,
829843
assertParamValue,
830844
assertPropValue,

lib/pool.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,14 +681,20 @@ class Pool extends EventEmitter {
681681
errors.assertParamPropBool(options, 1, "enableStatistics");
682682
errors.assertParamPropBool(options, 1, "resetStatistics");
683683
errors.assertParamPropUnsignedInt(options, 1, "poolMin");
684-
errors.assertParamPropUnsignedInt(options, 1, "poolMax");
684+
errors.assertParamPropUnsignedIntNonZero(options, 1, "poolMax");
685685
errors.assertParamPropUnsignedInt(options, 1, "poolMaxPerShard");
686686
errors.assertParamPropUnsignedInt(options, 1, "poolIncrement");
687687
errors.assertParamPropInt(options, 1, "poolPingInterval");
688688
errors.assertParamPropUnsignedInt(options, 1, "poolTimeout");
689689
errors.assertParamPropUnsignedInt(options, 1, "stmtCacheSize");
690690
errors.assertParamPropBool(options, 1, "sodaMetaDataCache");
691691

692+
// poolMax must be greater than or equal to poolMin
693+
if (options.poolMin > options.poolMax) {
694+
errors.throwErr(errors.ERR_INVALID_NUMBER_OF_CONNECTIONS, options.poolMax,
695+
options.poolMin);
696+
}
697+
692698
// reconfiguration can happen only when status is OPEN
693699
this._checkPoolOpen(false);
694700

test/poolReconfigure.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1165,14 +1165,18 @@ describe('255. poolReconfigure.js', function() {
11651165

11661166
await assert.rejects(
11671167
async () => await pool.reconfigure({poolMax: 0}),
1168-
/ORA-24413:/
1168+
/NJS-007:/
11691169
);
11701170

11711171
await assert.rejects(
11721172
async () => await pool.reconfigure({poolMax: "10"}),
11731173
/NJS-007:/
11741174
);
11751175

1176+
await assert.rejects(
1177+
async () => await pool.reconfigure({poolMax: 4, poolMin: 5}),
1178+
/NJS-092:/
1179+
);
11761180
});
11771181

11781182
it('255.5.4 passing invalid poolIncrement to pool.reconfigure', async function() {

0 commit comments

Comments
 (0)