fixed sonar issue in JdbcCachedDataSource 38/74638/1
authorRich Tabedzki <richard.tabedzki@att.com>
Thu, 13 Dec 2018 22:31:51 +0000 (17:31 -0500)
committerRich Tabedzki <richard.tabedzki@att.com>
Thu, 13 Dec 2018 22:32:43 +0000 (17:32 -0500)
Changes made:
* fixed sonar issue

Change-Id: I2112b202f8b7eb628fc21c3a972e35704dc827f9
Issue-ID: CCSDK-525
Signed-off-by: Rich Tabedzki <richard.tabedzki@att.com>
dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/config/BaseDBConfiguration.java
dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/jdbc/JdbcDBCachedDataSource.java

index 5f0209b..967059a 100755 (executable)
@@ -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);
     }
 
index 80ca577..09c1c20 100755 (executable)
@@ -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) {