Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Add parseIntNonNegative to allow 0 or larger values to ConnMaxLifetim…
Browse files Browse the repository at this point in the history
…eMilliseconds
  • Loading branch information
Jerry Kurian committed Jun 27, 2018
1 parent 1590023 commit 0c40911
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions components/admin_console/admin_settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,19 @@ export default class AdminSettings extends React.Component {
return n;
};

parseIntNonNegative = (str, defaultValue) => {
const n = parseInt(str, 10);

if (isNaN(n) || n < 0) {
if (defaultValue) {
return defaultValue;
}
return 0;
}

return n;
};

parseIntNonZero = (str, defaultValue) => {
const n = parseInt(str, 10);

Expand Down
2 changes: 1 addition & 1 deletion components/admin_console/database_settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class DatabaseSettings extends AdminSettings {

getConfigFromState(config) {
// driverName and dataSource are read-only from the UI
config.SqlSettings.ConnMaxLifetimeMilliseconds = this.parseInt(this.state.connMaxLifetimeMilliseconds);
config.SqlSettings.ConnMaxLifetimeMilliseconds = this.parseIntNonNegative(this.state.connMaxLifetimeMilliseconds);
config.SqlSettings.MaxIdleConns = this.parseIntNonZero(this.state.maxIdleConns);
config.SqlSettings.MaxOpenConns = this.parseIntNonZero(this.state.maxOpenConns);
config.SqlSettings.AtRestEncryptKey = this.state.atRestEncryptKey;
Expand Down

0 comments on commit 0c40911

Please sign in to comment.