Finish Hotfix-1
Some checks failed
IntegryManagementSystem_Multi/pipeline/head There was a failure building this commit

This commit is contained in:
2025-08-04 19:11:05 +02:00
4 changed files with 12 additions and 23 deletions

View File

@@ -700,16 +700,6 @@ public class EmsController {
logger.error(request.getRequestURI(), e);
ServiceRestResponse response = new ServiceRestResponse(EsitoType.KO, configuration, e);
responseList.add(response);
} finally {
if (multiDBTransactionManager != null) {
try {
multiDBTransactionManager.close();
} catch (Exception e) {
logger.error(request.getRequestURI(), e);
ServiceRestResponse response = new ServiceRestResponse(EsitoType.KO, configuration, e);
responseList.add(response);
}
}
}
return responseList;

View File

@@ -159,18 +159,17 @@ public class MultiDBTransactionManager implements AutoCloseable {
}
}
public Connection getDistributoreConnection() throws Exception {
Connection dsToReturn = null;
public String getDistributoreProfileName() throws PrimaryDatabaseNotPresentException {
for (Connection connection : allConnections) {
if (connection.isDistributore()) {
dsToReturn = connection;
return connection.getProfileName();
}
}
return getPrimaryConnection().getProfileName();
}
if (dsToReturn == null) dsToReturn = getPrimaryConnection();
return dsToReturn;
public Connection getDistributoreConnection() throws Exception {
return connectionPool.getConnection(settingsModel.findConnectionModel(getDistributoreProfileName()));
}
@@ -180,8 +179,9 @@ public class MultiDBTransactionManager implements AutoCloseable {
}
public PreparedStatement prepareStatementOnDistributore(String sql) throws Exception {
Connection connection = getDistributoreConnection();
return connection.prepareStatement(sql);
try (Connection connection = getDistributoreConnection()) {
return connection.prepareStatement(sql);
}
}
public List<Connection> getActiveConnections() throws SQLException {

View File

@@ -135,9 +135,8 @@ public class SyncManager {
private void proceedSyncronization(EntityInterface entitySource, EntityInterface entityCloned, StringBuffer[] lastProfileUsed, MultiDBTransactionManager multiDBTransactionManager) throws Exception {
Connection distributoreDatasource = multiDBTransactionManager.getDistributoreConnection();
String profileDbDistributore = distributoreDatasource.getProfileName();
List<StbSubscription> subscriptions = dynamicCacheService.getEntity(DynamicCacheService.Keys.ENTITY_SYNC_KEY, distributoreDatasource.getDbName());
String profileDbDistributore = multiDBTransactionManager.getDistributoreProfileName();
List<StbSubscription> subscriptions = dynamicCacheService.getEntity(DynamicCacheService.Keys.ENTITY_SYNC_KEY, profileDbDistributore);
if (subscriptions == null)
return;

View File

@@ -1408,7 +1408,7 @@ public class VariazioniPvService {
String userName = UtilityHashMap.getValueIfExists(export, "user_name");
String formatFile = UtilityHashMap.getValueIfExists(export, "format_file");
httpRestWrapper.callInternalExport(multiDBPv.getDistributoreConnection().getProfileName(),
httpRestWrapper.callInternalExport(multiDBPv.getDistributoreProfileName(),
userName,
exportType,
formatFile,