Skip to content

Commit

Permalink
improved checks for null condition (#69)
Browse files Browse the repository at this point in the history
improved checks for null condition on optional fields of workload-config.xml
  • Loading branch information
raffaelespazzoli authored Jan 14, 2021
1 parent d2d4a0a commit c4c5bf3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/com/oltpbenchmark/api/BenchmarkModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ public void createDataSource() throws SQLException {
props.setProperty("maximumPoolSize", Integer.toString(numConnections));
props.setProperty("connectionTimeout", Integer.toString(workConf.getHikariConnectionTimeout()));
props.setProperty("dataSource.reWriteBatchedInserts", "true");
if (workConf.getSslCert().length() > 0) {
if (workConf.getSslCert() != null && workConf.getSslCert().length() > 0) {
assert(workConf.getSslKey().length() > 0) : "The SSL key is empty.";
props.put("dataSource.sslmode", "require");
props.put("dataSource.sslcert", workConf.getSslCert());
props.put("dataSource.sslkey", workConf.getSslKey());
}
HikariConfig config = new HikariConfig(props);
if (workConf.getJdbcURL().length()>0) {
if (workConf.getJdbcURL() != null && workConf.getJdbcURL().length()>0) {
config.setJdbcUrl(workConf.getJdbcURL());
}
listDataSource.add(new HikariDataSource(config));
Expand All @@ -149,7 +149,7 @@ public final Connection makeConnection() throws SQLException {
props.put("user", workConf.getDBUsername());
props.put("password", workConf.getDBPassword());
props.put("reWriteBatchedInserts", "true");
if (workConf.getSslCert().length() > 0) {
if (workConf.getSslCert() != null && workConf.getSslCert().length() > 0) {
assert(workConf.getSslKey().length() > 0) : "The SSL key is empty.";
props.put("sslmode", "require");
props.put("sslcert", workConf.getSslCert());
Expand All @@ -158,7 +158,7 @@ public final Connection makeConnection() throws SQLException {

int r = dataSourceCounter.getAndIncrement() % workConf.getNodes().size();
String connectStr = null;
if (workConf.getJdbcURL().length()>0) {
if (workConf.getJdbcURL() != null && workConf.getJdbcURL().length()>0) {
connectStr=workConf.getJdbcURL();
} else {
connectStr = String.format("jdbc:postgresql://%s:%d/%s",
Expand Down

0 comments on commit c4c5bf3

Please sign in to comment.