MIFOSX-254 Make JDBC Pool Configuration Setting Work Better
Fix time-of-check-time-of-use bug in TomcatJdbcDataSourcePerTenantService.java Close database connection in ReadReportingServiceImpl.java
This commit is contained in:
+10
-7
@@ -44,13 +44,16 @@ public class TomcatJdbcDataSourcePerTenantService implements DataSourcePerTenant
|
||||
|
||||
MifosPlatformTenant tenant = ThreadLocalContextUtil.getTenant();
|
||||
if (tenant != null) {
|
||||
// if tenant information available switch to appropriate datasource
|
||||
// for that tenant.
|
||||
if (this.tenantToDataSourceMap.containsKey(tenant.getId())) {
|
||||
tenantDataSource = this.tenantToDataSourceMap.get(tenant.getId());
|
||||
} else {
|
||||
tenantDataSource = createNewDataSourceFor(tenant);
|
||||
this.tenantToDataSourceMap.put(tenant.getId(), tenantDataSource);
|
||||
synchronized(this.tenantToDataSourceMap)
|
||||
{
|
||||
// if tenant information available switch to appropriate datasource
|
||||
// for that tenant.
|
||||
if (this.tenantToDataSourceMap.containsKey(tenant.getId())) {
|
||||
tenantDataSource = this.tenantToDataSourceMap.get(tenant.getId());
|
||||
} else {
|
||||
tenantDataSource = createNewDataSourceFor(tenant);
|
||||
this.tenantToDataSourceMap.put(tenant.getId(), tenantDataSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-1
@@ -12,6 +12,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.sql.Connection;
|
||||
import java.sql.Date;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@@ -333,7 +334,16 @@ public class ReadReportingServiceImpl implements ReadReportingService {
|
||||
// passed as parameters to allow multitenant penaho reporting
|
||||
// and
|
||||
// data scoping
|
||||
String tenantdb = dataSource.getConnection().getCatalog();
|
||||
Connection connection = dataSource.getConnection();
|
||||
String tenantdb;
|
||||
try
|
||||
{
|
||||
tenantdb = connection.getCatalog();
|
||||
}
|
||||
finally
|
||||
{
|
||||
connection.close();
|
||||
}
|
||||
String userhierarchy = currentUser.getOffice().getHierarchy();
|
||||
logger.info("db name:" + tenantdb + " userhierarchy:" + userhierarchy);
|
||||
rptParamValues.put("tenantdb", tenantdb);
|
||||
|
||||
Reference in New Issue
Block a user