Skip to content
Permalink
Browse files

[CONJ-624] MariaDbPoolDataSource possible NPE on configuration getter

(cherry picked from commit ff9926c)
  • Loading branch information...
rusher committed Jul 6, 2018
1 parent f519f07 commit 991d1c794557020971718c8b611bb2e76acc2c86
@@ -423,6 +423,7 @@ public void setPoolName(String poolName) throws SQLException {
}

public int getMaxPoolSize() {
if (maxPoolSize == null) return 8;
return maxPoolSize;
}

@@ -432,6 +433,7 @@ public void setMaxPoolSize(int maxPoolSize) throws SQLException {
}

public int getMinPoolSize() {
if (minPoolSize == null) return getMaxPoolSize();
return minPoolSize;
}

@@ -441,6 +443,7 @@ public void setMinPoolSize(int minPoolSize) throws SQLException {
}

public int getMaxIdleTime() {
if (maxIdleTime == null) return 600;
return maxIdleTime;
}

@@ -458,6 +461,7 @@ public void setStaticGlobal(Boolean staticGlobal) {
}

public Integer getPoolValidMinDelay() {
if (poolValidMinDelay == null) return 1000;
return poolValidMinDelay;
}

@@ -73,6 +73,38 @@ public void testDataSourceEmpty() throws SQLException {
ds.close();
}


@Test
public void testDataSourcePool() throws SQLException {
MariaDbPoolDataSource ds = null;
try {
ds = new MariaDbPoolDataSource();
assertEquals(ds.getPort(), 3306);
assertEquals(ds.getMaxIdleTime(), 600);
assertEquals(ds.getMaxPoolSize(), 8);
assertEquals(ds.getMinPoolSize(), 8);
assertEquals(ds.getPoolValidMinDelay(), Integer.valueOf(1000));

ds.setPort(33006);
ds.setMaxPoolSize(10);
ds.setMaxIdleTime(500);
ds.setPoolValidMinDelay(500);

assertEquals(ds.getMaxIdleTime(), 500);
assertEquals(ds.getMaxPoolSize(), 10);
assertEquals(ds.getMinPoolSize(), 10);
assertEquals(ds.getPort(), 33006);
assertEquals(ds.getPoolValidMinDelay(), Integer.valueOf(500));

ds.setMinPoolSize(5);

assertEquals(ds.getMaxPoolSize(), 10);
assertEquals(ds.getMinPoolSize(), 5);
} finally {
if (ds != null) ds.close();
}
}

/**
* Conj-80.
*

0 comments on commit 991d1c7

Please sign in to comment.
You can’t perform that action at this time.