summaryrefslogtreecommitdiffstats
path: root/dblib
diff options
context:
space:
mode:
authorRich Tabedzki <richard.tabedzki@att.com>2018-12-13 17:31:51 -0500
committerRich Tabedzki <richard.tabedzki@att.com>2018-12-13 17:32:43 -0500
commit05102065e87889d6d4a8b8690d9ee6cdd4faf61d (patch)
tree140615c9aa7c91bb555232225beb4e660190990c /dblib
parent6dd2c1b07cc306750dd9ee93cf8bb2f615f076aa (diff)
fixed sonar issue in JdbcCachedDataSource
Changes made: * fixed sonar issue Change-Id: I2112b202f8b7eb628fc21c3a972e35704dc827f9 Issue-ID: CCSDK-525 Signed-off-by: Rich Tabedzki <richard.tabedzki@att.com>
Diffstat (limited to 'dblib')
-rwxr-xr-xdblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java6
-rwxr-xr-xdblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java39
2 files changed, 24 insertions, 21 deletions
diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java
index 5f0209b67..967059a31 100755
--- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java
+++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java
@@ -209,7 +209,7 @@ public abstract class BaseDBConfiguration {
* <code>Integer</code>.
*/
public int getDbMinLimit() throws NumberFormatException {
- String value = properties.getProperty(MIN_LIMIT);
+ String value = properties.getProperty(MIN_LIMIT, "-1");
return Integer.parseInt(value);
}
@@ -222,7 +222,7 @@ public abstract class BaseDBConfiguration {
* <code>Integer</code>.
*/
public int getDbMaxLimit() throws NumberFormatException {
- String value = properties.getProperty(MAX_LIMIT);
+ String value = properties.getProperty(MAX_LIMIT, "-1");
return Integer.parseInt(value);
}
@@ -235,7 +235,7 @@ public abstract class BaseDBConfiguration {
* <code>Integer</code>.
*/
public int getDbInitialLimit() throws NumberFormatException {
- String value = properties.getProperty(INIT_LIMIT);
+ String value = properties.getProperty(INIT_LIMIT, "-1");
return Integer.parseInt(value);
}
diff --git a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java
index 80ca577cf..09c1c202b 100755
--- a/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java
+++ b/dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java
@@ -42,6 +42,9 @@ public class JdbcDBCachedDataSource extends CachedDataSource {
private int initialLimit;
private static final String AS_CONF_ERROR = "AS_CONF_ERROR: ";
+ private static final int MIN_LIMIT = 5;
+ private static final int MAX_LIMIT = 10;
+ private static final int INITIAL_LIMIT = 10;
private static final Logger LOGGER = LoggerFactory.getLogger(JdbcDBCachedDataSource.class);
@@ -88,26 +91,26 @@ public class JdbcDBCachedDataSource extends CachedDataSource {
}
minLimit = jdbcConfig.getDbMinLimit();
-// if (minLimit == null)
-// {
-// String errorMsg = "Invalid XML contents: JDBC Connection missing minLimit attribute";
-// LOGGER.error(AS_CONF_ERROR + errorMsg);
-// throw new DBConfigException(errorMsg);
-// }
+ if (minLimit == -1)
+ {
+ String errorMsg = "Invalid XML contents: JDBC Connection missing minLimit attribute";
+ LOGGER.error(AS_CONF_ERROR + errorMsg);
+ minLimit = MIN_LIMIT;
+ }
maxLimit = jdbcConfig.getDbMaxLimit();
-// if (maxLimit == null)
-// {
-// String errorMsg = "Invalid XML contents: JDBC Connection missing maxLimit attribute";
-// LOGGER.error(AS_CONF_ERROR + errorMsg);
-// throw new DBConfigException(errorMsg);
-// }
+ if (maxLimit == -1)
+ {
+ String errorMsg = "Invalid XML contents: JDBC Connection missing maxLimit attribute";
+ LOGGER.error(AS_CONF_ERROR + errorMsg);
+ maxLimit = MAX_LIMIT;
+ }
initialLimit = jdbcConfig.getDbInitialLimit();
-// if (initialLimit == null)
-// {
-// String errorMsg = "Invalid XML contents: JDBC Connection missing initialLimit attribute";
-// LOGGER.error(AS_CONF_ERROR + errorMsg);
-// throw new DBConfigException(errorMsg);
-// }
+ if (initialLimit == -1)
+ {
+ String errorMsg = "Invalid XML contents: JDBC Connection missing initialLimit attribute";
+ LOGGER.error(AS_CONF_ERROR + errorMsg);
+ initialLimit = INITIAL_LIMIT;
+ }
dbUrl = jdbcConfig.getDbUrl();
if (dbUrl == null) {