This is an automated email from the ASF dual-hosted git repository.

dahn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git

commit 9032fe3fb53c49b6f13739cf371944ed75f77cc7
Merge: 8171d9568c9 e23c7ef7017
Author: Daan Hoogland <[email protected]>
AuthorDate: Wed Nov 26 11:55:50 2025 +0100

    merge LTS branch 4.22 into main

 .../conf/uefi.properties.in                        |  19 +--
 .../user/address/ListPublicIpAddressesCmd.java     |   2 +-
 debian/cloudstack-agent.install                    |   1 +
 debian/cloudstack-agent.postinst                   |   2 +-
 debian/control                                     |   2 +-
 .../main/java/com/cloud/event/UsageEventUtils.java |  12 ++
 .../engine/orchestration/VolumeOrchestrator.java   |   4 +-
 .../main/java/com/cloud/event/UsageEventVO.java    |  22 +++
 .../com/cloud/event/dao/UsageEventDaoImpl.java     |   8 +-
 .../com/cloud/upgrade/DatabaseUpgradeChecker.java  |  50 +++---
 ...e42200to42300.java => Upgrade42200to42210.java} |   6 +-
 ...e42200to42300.java => Upgrade42210to42300.java} |   4 +-
 .../main/java/com/cloud/usage/UsageVolumeVO.java   |  14 +-
 .../com/cloud/usage/dao/UsageStorageDaoImpl.java   |   2 +
 .../java/com/cloud/usage/dao/UsageVolumeDao.java   |   6 +-
 .../com/cloud/usage/dao/UsageVolumeDaoImpl.java    |  86 ++++-------
 .../main/java/com/cloud/vm/dao/UserVmDaoImpl.java  |   2 +-
 .../META-INF/db/schema-42200to42210-cleanup.sql    |  20 +++
 .../resources/META-INF/db/schema-42200to42210.sql  |  27 ++++
 .../java/com/cloud/utils/db/TransactionLegacy.java | 146 +++++++++---------
 packaging/debian/replace.properties                |   5 +
 packaging/el8/cloud.spec                           |  13 +-
 packaging/el8/replace.properties                   |   5 +
 .../cloudstack/backup/veeam/VeeamClient.java       |  45 +++---
 .../cloudstack/backup/veeam/VeeamClientTest.java   |   4 +-
 .../kvm/resource/LibvirtComputingResource.java     |  16 +-
 .../java/com/cloud/hypervisor/guru/VMwareGuru.java |   7 +-
 .../cluster/KubernetesClusterService.java          |   2 +-
 .../cloudstack/ldap/ADLdapUserManagerImpl.java     |  18 ++-
 .../cloudstack/ldap/OpenLdapUserManagerImpl.java   | 139 ++++++++---------
 .../cloudstack/ldap/ADLdapUserManagerImplTest.java |   5 +-
 pom.xml                                            |   4 +
 .../main/java/com/cloud/api/ApiResponseHelper.java |   3 +
 server/src/main/java/com/cloud/api/ApiServer.java  |  28 +++-
 .../main/java/com/cloud/hypervisor/KVMGuru.java    |   6 +
 .../com/cloud/server/ManagementServerImpl.java     |  55 ++++---
 .../com/cloud/storage/VolumeApiServiceImpl.java    |  17 ++-
 .../storage/listener/VolumeStateListener.java      |   2 +-
 .../main/java/com/cloud/vm/UserVmManagerImpl.java  |   6 +-
 .../com/cloud/server/ManagementServerImplTest.java |  66 ++++++--
 .../cloud/storage/VolumeApiServiceImplTest.java    |   8 +-
 .../java/com/cloud/vm/UserVmManagerImplTest.java   |   8 +-
 setup/bindir/cloud-setup-databases.in              |  12 +-
 systemvm/systemvm-agent-descriptor.xml             |   1 +
 ui/public/locales/en.json                          |   2 +-
 .../components/view/ImageDeployInstanceButton.vue  |  35 +++--
 ui/src/components/view/SettingsTab.vue             |   3 +-
 ui/src/components/widgets/InfiniteScrollSelect.vue |  24 ++-
 .../compute/wizard/ZoneBlockRadioGroupSelect.vue   |   2 +-
 ui/src/views/network/IpAddressesTab.vue            |  84 +++++------
 ui/src/views/setting/ConfigurationTable.vue        |   6 +-
 ui/src/views/setting/ConfigurationValue.vue        |  16 ++
 .../java/com/cloud/usage/UsageManagerImpl.java     | 167 ++++++++++++---------
 .../com/cloud/usage/parser/VolumeUsageParser.java  |  23 ++-
 utils/src/main/java/com/cloud/utils/EnumUtils.java |   2 +-
 .../cloudstack/utils/process/ProcessRunner.java    |  11 +-
 .../utils/process/ProcessRunnerTest.java           |  12 ++
 57 files changed, 775 insertions(+), 522 deletions(-)

diff --cc 
engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java
index ee8055f5c56,bf660f37bc3..004a5f9dd65
--- a/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java
+++ b/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java
@@@ -89,10 -90,10 +89,11 @@@ import com.cloud.upgrade.dao.Upgrade419
  import com.cloud.upgrade.dao.Upgrade41910to42000;
  import com.cloud.upgrade.dao.Upgrade42000to42010;
  import com.cloud.upgrade.dao.Upgrade42010to42100;
- import com.cloud.upgrade.dao.Upgrade420to421;
  import com.cloud.upgrade.dao.Upgrade42100to42200;
+ import com.cloud.upgrade.dao.Upgrade42200to42210;
+ import com.cloud.upgrade.dao.Upgrade420to421;
  import com.cloud.upgrade.dao.Upgrade421to430;
- import com.cloud.upgrade.dao.Upgrade42200to42300;
++import com.cloud.upgrade.dao.Upgrade42210to42300;
  import com.cloud.upgrade.dao.Upgrade430to440;
  import com.cloud.upgrade.dao.Upgrade431to440;
  import com.cloud.upgrade.dao.Upgrade432to440;
@@@ -237,7 -237,7 +238,8 @@@ public class DatabaseUpgradeChecker imp
                  .next("4.20.0.0", new Upgrade42000to42010())
                  .next("4.20.1.0", new Upgrade42010to42100())
                  .next("4.21.0.0", new Upgrade42100to42200())
-                 .next("4.22.0.0", new Upgrade42200to42300())
+                 .next("4.22.0.0", new Upgrade42200to42210())
++                .next("4.22.1.0", new Upgrade42210to42300())
                  .build();
      }
  
@@@ -315,20 -315,20 +317,20 @@@
      }
  
      protected void executeProcedureScripts() {
--        LOGGER.info(String.format("Executing Stored Procedure scripts that 
are under resource directory [%s].", PROCEDURES_DIRECTORY));
++        LOGGER.info("Executing Stored Procedure scripts that are under 
resource directory [{}].", PROCEDURES_DIRECTORY);
          List<String> filesPathUnderViewsDirectory = 
FileUtil.getFilesPathsUnderResourceDirectory(PROCEDURES_DIRECTORY);
  
          try (TransactionLegacy txn = 
TransactionLegacy.open("execute-procedure-scripts")) {
              Connection conn = txn.getConnection();
  
              for (String filePath : filesPathUnderViewsDirectory) {
--                LOGGER.debug(String.format("Executing PROCEDURE script 
[%s].", filePath));
++                LOGGER.debug("Executing PROCEDURE script [{}].", filePath);
  
                  InputStream viewScript = 
Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath);
                  runScript(conn, viewScript);
              }
  
--            LOGGER.info(String.format("Finished execution of PROCEDURE 
scripts that are under resource directory [%s].", PROCEDURES_DIRECTORY));
++            LOGGER.info("Finished execution of PROCEDURE scripts that are 
under resource directory [{}].", PROCEDURES_DIRECTORY);
          } catch (SQLException e) {
              String message = String.format("Unable to execute PROCEDURE 
scripts due to [%s].", e.getMessage());
              LOGGER.error(message, e);
@@@ -337,7 -337,7 +339,7 @@@
      }
  
      private DbUpgrade[] executeUpgrades(CloudStackVersion dbVersion, 
CloudStackVersion currentVersion) {
--        LOGGER.info("Database upgrade must be performed from " + dbVersion + 
" to " + currentVersion);
++        LOGGER.info("Database upgrade must be performed from {} to {}", 
dbVersion, currentVersion);
  
          final DbUpgrade[] upgrades = calculateUpgradePath(dbVersion, 
currentVersion);
  
@@@ -350,8 -350,8 +352,8 @@@
  
      private VersionVO executeUpgrade(DbUpgrade upgrade) {
          VersionVO version;
--        LOGGER.debug("Running upgrade " + upgrade.getClass().getSimpleName() 
+ " to upgrade from " + upgrade.getUpgradableVersionRange()[0] + "-" + upgrade
--            .getUpgradableVersionRange()[1] + " to " + 
upgrade.getUpgradedVersion());
++        LOGGER.debug("Running upgrade {} to upgrade from {}-{} to {}", 
upgrade.getClass().getSimpleName(), upgrade.getUpgradableVersionRange()[0], 
upgrade
++                .getUpgradableVersionRange()[1], 
upgrade.getUpgradedVersion());
          TransactionLegacy txn = TransactionLegacy.open("Upgrade");
          txn.start();
          try {
@@@ -394,8 -394,8 +396,8 @@@
          // Run the corresponding '-cleanup.sql' script
          txn = TransactionLegacy.open("Cleanup");
          try {
--            LOGGER.info("Cleanup upgrade " + 
upgrade.getClass().getSimpleName() + " to upgrade from " + 
upgrade.getUpgradableVersionRange()[0] + "-" + upgrade
--                .getUpgradableVersionRange()[1] + " to " + 
upgrade.getUpgradedVersion());
++            LOGGER.info("Cleanup upgrade {} to upgrade from {}-{} to {}", 
upgrade.getClass().getSimpleName(), upgrade.getUpgradableVersionRange()[0], 
upgrade
++                    .getUpgradableVersionRange()[1], 
upgrade.getUpgradedVersion());
  
              txn.start();
              Connection conn;
@@@ -410,7 -410,7 +412,7 @@@
              if (scripts != null) {
                  for (InputStream script : scripts) {
                      runScript(conn, script);
--                    LOGGER.debug("Cleanup script " + 
upgrade.getClass().getSimpleName() + " is executed successfully");
++                    LOGGER.debug("Cleanup script {} is executed 
successfully", upgrade.getClass().getSimpleName());
                  }
              }
              txn.commit();
@@@ -420,27 -420,27 +422,27 @@@
              version.setUpdated(new Date());
              _dao.update(version.getId(), version);
              txn.commit();
--            LOGGER.debug("Upgrade completed for version " + 
version.getVersion());
++            LOGGER.debug("Upgrade completed for version {}", 
version.getVersion());
          } finally {
              txn.close();
          }
      }
  
      protected void executeViewScripts() {
--        LOGGER.info(String.format("Executing VIEW scripts that are under 
resource directory [%s].", VIEWS_DIRECTORY));
++        LOGGER.info("Executing VIEW scripts that are under resource directory 
[{}].", VIEWS_DIRECTORY);
          List<String> filesPathUnderViewsDirectory = 
FileUtil.getFilesPathsUnderResourceDirectory(VIEWS_DIRECTORY);
  
          try (TransactionLegacy txn = 
TransactionLegacy.open("execute-view-scripts")) {
              Connection conn = txn.getConnection();
  
              for (String filePath : filesPathUnderViewsDirectory) {
--                LOGGER.debug(String.format("Executing VIEW script [%s].", 
filePath));
++                LOGGER.debug("Executing VIEW script [{}].", filePath);
  
                  InputStream viewScript = 
Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath);
                  runScript(conn, viewScript);
              }
  
--            LOGGER.info(String.format("Finished execution of VIEW scripts 
that are under resource directory [%s].", VIEWS_DIRECTORY));
++            LOGGER.info("Finished execution of VIEW scripts that are under 
resource directory [{}].", VIEWS_DIRECTORY);
          } catch (SQLException e) {
              String message = String.format("Unable to execute VIEW scripts 
due to [%s].", e.getMessage());
              LOGGER.error(message, e);
@@@ -470,10 -470,10 +472,10 @@@
                  String csVersion = 
SystemVmTemplateRegistration.parseMetadataFile();
                  final CloudStackVersion sysVmVersion = 
CloudStackVersion.parse(csVersion);
                  final  CloudStackVersion currentVersion = 
CloudStackVersion.parse(currentVersionValue);
--                SystemVmTemplateRegistration.CS_MAJOR_VERSION  = 
String.valueOf(sysVmVersion.getMajorRelease()) + "." + 
String.valueOf(sysVmVersion.getMinorRelease());
++                SystemVmTemplateRegistration.CS_MAJOR_VERSION  = 
sysVmVersion.getMajorRelease() + "." + sysVmVersion.getMinorRelease();
                  SystemVmTemplateRegistration.CS_TINY_VERSION = 
String.valueOf(sysVmVersion.getPatchRelease());
  
--                LOGGER.info("DB version = " + dbVersion + " Code Version = " 
+ currentVersion);
++                LOGGER.info("DB version = {} Code Version = {}", dbVersion, 
currentVersion);
  
                  if (dbVersion.compareTo(currentVersion) > 0) {
                      throw new CloudRuntimeException("Database version " + 
dbVersion + " is higher than management software version " + 
currentVersionValue);
@@@ -522,7 -522,7 +524,7 @@@
               ResultSet result = pstmt.executeQuery()) {
              if (result.next()) {
                  String init = result.getString(1);
--                LOGGER.info("init = " + DBEncryptionUtil.decrypt(init));
++                LOGGER.info("init = {}", DBEncryptionUtil.decrypt(init));
              }
          }
      }
@@@ -553,21 -553,21 +555,11 @@@
              return upgradedVersion;
          }
  
--        @Override
--        public boolean supportsRollingUpgrade() {
--            return false;
--        }
--
          @Override
          public InputStream[] getPrepareScripts() {
              return new InputStream[0];
          }
  
--        @Override
--        public void performDataMigration(Connection conn) {
--
--        }
--
          @Override
          public InputStream[] getCleanupScripts() {
              return new InputStream[0];
diff --cc 
engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42210to42300.java
index 0ea04c1a216,9676badb4e9..cb87e730f83
--- a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42210to42300.java
+++ b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade42210to42300.java
@@@ -14,17 -14,31 +14,17 @@@
  // KIND, either express or implied.  See the License for the
  // specific language governing permissions and limitations
  // under the License.
 -package com.cloud.network;
 +package com.cloud.upgrade.dao;
  
- public class Upgrade42200to42300 extends DbUpgradeAbstractImpl implements 
DbUpgrade, DbUpgradeSystemVmTemplate {
 -import org.apache.cloudstack.api.Identity;
 -import org.apache.cloudstack.api.InternalIdentity;
++public class Upgrade42210to42300 extends DbUpgradeAbstractImpl implements 
DbUpgrade, DbUpgradeSystemVmTemplate {
  
 -import com.cloud.network.Networks.TrafficType;
 +    @Override
 +    public String[] getUpgradableVersionRange() {
-         return new String[]{"4.22.0.0", "4.23.0.0"};
++        return new String[]{"4.22.1.0", "4.23.0.0"};
 +    }
  
 -/**
 - *
 - */
 -public interface PhysicalNetworkTrafficType extends InternalIdentity, 
Identity {
 -
 -    long getPhysicalNetworkId();
 -
 -    TrafficType getTrafficType();
 -
 -    String getXenNetworkLabel();
 -
 -    String getKvmNetworkLabel();
 -
 -    String getVmwareNetworkLabel();
 -
 -    String getSimulatorNetworkLabel();
 -
 -    String getHypervNetworkLabel();
 -
 -    String getOvm3NetworkLabel();
 +    @Override
 +    public String getUpgradedVersion() {
 +        return "4.23.0.0";
 +    }
  }
diff --cc framework/db/src/main/java/com/cloud/utils/db/TransactionLegacy.java
index 18a90749e49,18a90749e49..13faff37136
--- a/framework/db/src/main/java/com/cloud/utils/db/TransactionLegacy.java
+++ b/framework/db/src/main/java/com/cloud/utils/db/TransactionLegacy.java
@@@ -25,10 -25,10 +25,7 @@@ import java.sql.ResultSet
  import java.sql.SQLException;
  import java.sql.Savepoint;
  import java.sql.Statement;
--import java.util.Iterator;
--import java.util.LinkedList;
--import java.util.List;
--import java.util.Properties;
++import java.util.*;
  import java.util.concurrent.atomic.AtomicLong;
  
  import javax.sql.DataSource;
@@@ -56,14 -56,14 +53,12 @@@ import com.zaxxer.hikari.HikariDataSour
  /**
   * Transaction abstracts away the Connection object in JDBC.  It allows the
   * following things that the Connection object does not.
-- *
   *   1. Transaction can be started at an entry point and whether the DB
   *      actions should be auto-commit or not determined at that point.
   *   2. DB Connection is allocated only when it is needed.
   *   3. Code does not need to know if a transaction has been started or not.
   *      It just starts/ends a transaction and we resolve it correctly with
   *      the previous actions.
-- *
   * Note that this class is not synchronous but it doesn't need to be because
   * it is stored with TLS and is one per thread.  Use appropriately.
   */
@@@ -73,7 -73,7 +68,7 @@@ public class TransactionLegacy implemen
      protected Logger lockLogger = 
LogManager.getLogger(Transaction.class.getName() + "." + "Lock");
      protected static Logger CONN_LOGGER = 
LogManager.getLogger(Transaction.class.getName() + "." + "Connection");
  
--    private static final ThreadLocal<TransactionLegacy> tls = new 
ThreadLocal<TransactionLegacy>();
++    private static final ThreadLocal<TransactionLegacy> tls = new 
ThreadLocal<>();
      private static final String START_TXN = "start_txn";
      private static final String CURRENT_TXN = "current_txn";
      private static final String CREATE_TXN = "create_txn";
@@@ -103,7 -103,7 +98,7 @@@
      private final LinkedList<StackElement> _stack;
      private long _id;
  
--    private final LinkedList<Pair<String, Long>> _lockTimes = new 
LinkedList<Pair<String, Long>>();
++    private final LinkedList<Pair<String, Long>> _lockTimes = new 
LinkedList<>();
  
      private String _name;
      private Connection _conn;
@@@ -160,7 -160,7 +155,7 @@@
          TransactionLegacy txn = tls.get();
          if (txn == null) {
              if (LOGGER.isTraceEnabled()) {
--                LOGGER.trace("Creating the transaction: " + name);
++                LOGGER.trace("Creating the transaction: {}", name);
              }
              txn = new TransactionLegacy(name, false, databaseId);
              tls.set(txn);
@@@ -206,7 -206,7 +201,7 @@@
  
      public void registerLock(String sql) {
          if (_txn && lockLogger.isDebugEnabled()) {
--            Pair<String, Long> time = new Pair<String, Long>(sql, 
System.currentTimeMillis());
++            Pair<String, Long> time = new Pair<>(sql, 
System.currentTimeMillis());
              _lockTimes.add(time);
          }
      }
@@@ -218,7 -218,7 +213,7 @@@
      public static Connection getStandaloneConnectionWithException() throws 
SQLException {
          Connection conn = s_ds.getConnection();
          if (CONN_LOGGER.isTraceEnabled()) {
--            CONN_LOGGER.trace("Retrieving a standalone connection: dbconn" + 
System.identityHashCode(conn));
++            CONN_LOGGER.trace("Retrieving a standalone connection: dbconn{}", 
System.identityHashCode(conn));
          }
          return conn;
      }
@@@ -236,7 -236,7 +231,7 @@@
          try {
              Connection conn = s_usageDS.getConnection();
              if (CONN_LOGGER.isTraceEnabled()) {
--                CONN_LOGGER.trace("Retrieving a standalone connection for 
usage: dbconn" + System.identityHashCode(conn));
++                CONN_LOGGER.trace("Retrieving a standalone connection for 
usage: dbconn{}", System.identityHashCode(conn));
              }
              return conn;
          } catch (SQLException e) {
@@@ -249,7 -249,7 +244,7 @@@
          try {
              Connection conn = s_simulatorDS.getConnection();
              if (CONN_LOGGER.isTraceEnabled()) {
--                CONN_LOGGER.trace("Retrieving a standalone connection for 
simulator: dbconn" + System.identityHashCode(conn));
++                CONN_LOGGER.trace("Retrieving a standalone connection for 
simulator: dbconn{}", System.identityHashCode(conn));
              }
              return conn;
          } catch (SQLException e) {
@@@ -266,7 -266,7 +261,7 @@@
          Iterator<StackElement> it = _stack.descendingIterator();
          while (it.hasNext()) {
              StackElement element = it.next();
--            if (element.type == ATTACHMENT) {
++            if (Objects.equals(element.type, ATTACHMENT)) {
                  TransactionAttachment att = 
(TransactionAttachment)element.ref;
                  if (name.equals(att.getName())) {
                      it.remove();
@@@ -308,7 -308,7 +303,7 @@@
          }
  
          // relax stack structure for several places that @DB required 
injection is not in place
--        LOGGER.warn("Non-standard stack context that Transaction context is 
manaully placed into the calling chain. Stack chain: " + sb);
++        LOGGER.warn("Non-standard stack context that Transaction context is 
manaully placed into the calling chain. Stack chain: {}", sb);
          return true;
      }
  
@@@ -344,7 -344,7 +339,7 @@@
      private TransactionLegacy(final String name, final boolean forLocking, 
final short databaseId) {
          _name = name;
          _conn = null;
--        _stack = new LinkedList<StackElement>();
++        _stack = new LinkedList<>();
          _txn = false;
          _dbId = databaseId;
          _id = s_id.incrementAndGet();
@@@ -372,7 -372,7 +367,7 @@@
          final StringBuilder str = new StringBuilder((_name != null ? _name : 
""));
          str.append(" : ");
          for (final StackElement se : _stack) {
--            if (se.type == CURRENT_TXN) {
++            if (Objects.equals(se.type, CURRENT_TXN)) {
                  str.append(se.ref).append(", ");
              }
          }
@@@ -406,7 -406,7 +401,7 @@@
      @Deprecated
      public void start() {
          if (LOGGER.isTraceEnabled()) {
--            LOGGER.trace("txn: start requested by: " + buildName());
++            LOGGER.trace("txn: start requested by: {}", buildName());
          }
  
          _stack.push(new StackElement(START_TXN, null));
@@@ -434,7 -434,7 +429,7 @@@
          if (_stmt != null) {
              try {
                  if (stmtLogger.isTraceEnabled()) {
--                    stmtLogger.trace("Closing: " + _stmt.toString());
++                    stmtLogger.trace("Closing: {}", _stmt.toString());
                  }
                  try {
                      ResultSet rs = _stmt.getResultSet();
@@@ -446,7 -446,7 +441,7 @@@
                  }
                  _stmt.close();
              } catch (final SQLException e) {
--                stmtLogger.trace("Unable to close statement: " + 
_stmt.toString());
++                stmtLogger.trace("Unable to close statement: {}", 
_stmt.toString());
              } finally {
                  _stmt = null;
              }
@@@ -474,7 -474,7 +469,7 @@@
          final Connection conn = getConnection();
          final PreparedStatement pstmt = conn.prepareStatement(sql);
          if (stmtLogger.isTraceEnabled()) {
--            stmtLogger.trace("Preparing: " + sql);
++            stmtLogger.trace("Preparing: {}", sql);
          }
          return pstmt;
      }
@@@ -494,7 -494,7 +489,7 @@@
          final Connection conn = getConnection();
          final PreparedStatement pstmt = conn.prepareStatement(sql, 
autoGeneratedKeys);
          if (stmtLogger.isTraceEnabled()) {
--            stmtLogger.trace("Preparing: " + sql);
++            stmtLogger.trace("Preparing: {}", sql);
          }
          closePreviousStatement();
          _stmt = pstmt;
@@@ -516,7 -516,7 +511,7 @@@
          final Connection conn = getConnection();
          final PreparedStatement pstmt = conn.prepareStatement(sql, 
columnNames);
          if (stmtLogger.isTraceEnabled()) {
--            stmtLogger.trace("Preparing: " + sql);
++            stmtLogger.trace("Preparing: {}", sql);
          }
          closePreviousStatement();
          _stmt = pstmt;
@@@ -537,7 -537,7 +532,7 @@@
          final Connection conn = getConnection();
          final PreparedStatement pstmt = conn.prepareStatement(sql, 
resultSetType, resultSetConcurrency, resultSetHoldability);
          if (stmtLogger.isTraceEnabled()) {
--            stmtLogger.trace("Preparing: " + sql);
++            stmtLogger.trace("Preparing: {}", sql);
          }
          closePreviousStatement();
          _stmt = pstmt;
@@@ -546,7 -546,7 +541,6 @@@
  
      /**
       * Returns the db connection.
--     *
       * Note: that you can call getConnection() but beaware that
       * all prepare statements from the Connection are not garbage
       * collected!
@@@ -595,8 -595,8 +589,7 @@@
              //
              _stack.push(new StackElement(CREATE_CONN, null));
              if (CONN_LOGGER.isTraceEnabled()) {
--                CONN_LOGGER.trace("Creating a DB connection with " + (_txn ? 
" txn: " : " no txn: ") + " for " + _dbId + ": dbconn" + 
System.identityHashCode(_conn) +
--                        ". Stack: " + buildName());
++                CONN_LOGGER.trace("Creating a DB connection with {} for {}: 
dbconn{}. Stack: {}", _txn ? " txn: " : " no txn: ", _dbId, 
System.identityHashCode(_conn), buildName());
              }
          } else {
              LOGGER.trace("conn: Using existing DB connection");
@@@ -615,33 -615,33 +608,33 @@@
      }
  
      protected boolean takeOver(final String name, final boolean create) {
--        if (_stack.size() != 0) {
++        if (!_stack.isEmpty()) {
              if (!create) {
                  // If it is not a create transaction, then let's just use the 
current one.
                  if (LOGGER.isTraceEnabled()) {
--                    LOGGER.trace("Using current transaction: " + toString());
++                    LOGGER.trace("Using current transaction: {}", this);
                  }
                  mark(name);
                  return false;
              }
  
              final StackElement se = _stack.getFirst();
--            if (se.type == CREATE_TXN) {
++            if (Objects.equals(se.type, CREATE_TXN)) {
                  // This create is called inside of another create.  Which is 
ok?
                  // We will let that create be responsible for cleaning up.
                  if (LOGGER.isTraceEnabled()) {
--                    LOGGER.trace("Create using current transaction: " + 
toString());
++                    LOGGER.trace("Create using current transaction: {}", 
this);
                  }
                  mark(name);
                  return false;
              }
  
--            LOGGER.warn("Encountered a transaction that has leaked.  Cleaning 
up. " + toString());
++            LOGGER.warn("Encountered a transaction that has leaked.  Cleaning 
up. {}", this);
              cleanup();
          }
  
          if (LOGGER.isTraceEnabled()) {
--            LOGGER.trace("Took over the transaction: " + name);
++            LOGGER.trace("Took over the transaction: {}", name);
          }
          _stack.push(new StackElement(create ? CREATE_TXN : CURRENT_TXN, 
name));
          _name = name;
@@@ -671,7 -671,7 +664,7 @@@
      public void close() {
          removeUpTo(CURRENT_TXN, null);
  
--        if (_stack.size() == 0) {
++        if (_stack.isEmpty()) {
              LOGGER.trace("Transaction is done");
              cleanup();
          }
@@@ -687,7 -687,7 +680,7 @@@
      public boolean close(final String name) {
          if (_name == null) {    // Already cleaned up.
              if (LOGGER.isTraceEnabled()) {
--                LOGGER.trace("Already cleaned up." + buildName());
++                LOGGER.trace("Already cleaned up.{}", buildName());
              }
              return true;
          }
@@@ -698,7 -698,7 +691,7 @@@
          }
  
          if (LOGGER.isDebugEnabled() && _stack.size() > 2) {
--            LOGGER.debug("Transaction is not closed properly: " + toString() 
+ ".  Called by " + buildName());
++            LOGGER.debug("Transaction is not closed properly: {}.  Called by 
{}", this, buildName());
          }
  
          cleanup();
@@@ -714,7 -714,7 +707,7 @@@
      protected void clearLockTimes() {
          if (lockLogger.isDebugEnabled()) {
              for (Pair<String, Long> time : _lockTimes) {
--                lockLogger.trace("SQL " + time.first() + " took " + 
(System.currentTimeMillis() - time.second()));
++                lockLogger.trace("SQL {} took {}", time.first(), 
System.currentTimeMillis() - time.second());
              }
              _lockTimes.clear();
          }
@@@ -722,14 -722,14 +715,14 @@@
  
      public boolean commit() {
          if (!_txn) {
--            LOGGER.warn("txn: Commit called when it is not a transaction: " + 
buildName());
++            LOGGER.warn("txn: Commit called when it is not a transaction: 
{}", buildName());
              return false;
          }
  
          Iterator<StackElement> it = _stack.iterator();
          while (it.hasNext()) {
              StackElement st = it.next();
--            if (st.type == START_TXN) {
++            if (Objects.equals(st.type, START_TXN)) {
                  it.remove();
                  break;
              }
@@@ -737,7 -737,7 +730,7 @@@
  
          if (hasTxnInStack()) {
              if (LOGGER.isTraceEnabled()) {
--                LOGGER.trace("txn: Not committing because transaction started 
elsewhere: " + buildName() + " / " + toString());
++                LOGGER.trace("txn: Not committing because transaction started 
elsewhere: {} / {}", buildName(), this);
              }
              return false;
          }
@@@ -746,7 -746,7 +739,7 @@@
          try {
              if (_conn != null) {
                  _conn.commit();
--                LOGGER.trace("txn: DB Changes committed. Time = " + 
(System.currentTimeMillis() - _txnTime));
++                LOGGER.trace("txn: DB Changes committed. Time = {}", 
System.currentTimeMillis() - _txnTime);
                  clearLockTimes();
                  closeConnection();
              }
@@@ -773,7 -773,7 +766,7 @@@
              // we should only close db connection when it is not user managed
              if (_dbId != CONNECTED_DB) {
                  if (CONN_LOGGER.isTraceEnabled()) {
--                    CONN_LOGGER.trace("Closing DB connection: dbconn" + 
System.identityHashCode(_conn));
++                    CONN_LOGGER.trace("Closing DB connection: dbconn{}", 
System.identityHashCode(_conn));
                  }
                  _conn.close();
                  _conn = null;
@@@ -797,13 -797,13 +790,13 @@@
                      break;
                  }
  
--                if (item.type == CURRENT_TXN) {
++                if (Objects.equals(item.type, CURRENT_TXN)) {
                      if (LOGGER.isTraceEnabled()) {
--                        LOGGER.trace("Releasing the current txn: " + 
(item.ref != null ? item.ref : ""));
++                        LOGGER.trace("Releasing the current txn: {}", 
item.ref != null ? item.ref : "");
                      }
--                } else if (item.type == CREATE_CONN) {
++                } else if (Objects.equals(item.type, CREATE_CONN)) {
                      closeConnection();
--                } else if (item.type == START_TXN) {
++                } else if (Objects.equals(item.type, START_TXN)) {
                      if (item.ref == null) {
                          rollback = true;
                      } else {
@@@ -814,10 -814,10 +807,10 @@@
                              LOGGER.warn("Unable to rollback Txn.", e);
                          }
                      }
--                } else if (item.type == STATEMENT) {
++                } else if (Objects.equals(item.type, STATEMENT)) {
                      try {
                          if (stmtLogger.isTraceEnabled()) {
--                            stmtLogger.trace("Closing: " + ref.toString());
++                            stmtLogger.trace("Closing: {}", ref.toString());
                          }
                          Statement stmt = (Statement)ref;
                          try {
@@@ -830,17 -830,17 +823,17 @@@
                          }
                          stmt.close();
                      } catch (final SQLException e) {
--                        stmtLogger.trace("Unable to close statement: " + 
item);
++                        stmtLogger.trace("Unable to close statement: {}", 
item);
                      }
--                } else if (item.type == ATTACHMENT) {
++                } else if (Objects.equals(item.type, ATTACHMENT)) {
                      TransactionAttachment att = 
(TransactionAttachment)item.ref;
                      if (LOGGER.isTraceEnabled()) {
--                        LOGGER.trace("Cleaning up " + att.getName());
++                        LOGGER.trace("Cleaning up {}", att.getName());
                      }
                      att.cleanup();
                  }
              } catch (Exception e) {
--                LOGGER.error("Unable to clean up " + item, e);
++                LOGGER.error("Unable to clean up {}", item, e);
              }
          }
  
@@@ -853,7 -853,7 +846,7 @@@
          closePreviousStatement();
          if (!_txn) {
              if (LOGGER.isTraceEnabled()) {
--                LOGGER.trace("Rollback called for " + _name + " when there's 
no transaction: " + buildName());
++                LOGGER.trace("Rollback called for {} when there's no 
transaction: {}", _name, buildName());
              }
              return;
          }
@@@ -862,7 -862,7 +855,7 @@@
          try {
              if (_conn != null) {
                  if (LOGGER.isDebugEnabled()) {
--                    LOGGER.debug("Rolling back the transaction: Time = " + 
(System.currentTimeMillis() - _txnTime) + " Name =  " + _name + "; called by " 
+ buildName());
++                    LOGGER.debug("Rolling back the transaction: Time = {} 
Name =  {}; called by {}", System.currentTimeMillis() - _txnTime, _name, 
buildName());
                  }
                  _conn.rollback();
              }
@@@ -879,7 -879,7 +872,7 @@@
                  _conn.rollback(sp);
              }
          } catch (SQLException e) {
--            LOGGER.warn("Unable to rollback to savepoint " + sp);
++            LOGGER.warn("Unable to rollback to savepoint {}", sp);
          }
  
          if (!hasTxnInStack()) {
@@@ -892,7 -892,7 +885,7 @@@
          Iterator<StackElement> it = _stack.iterator();
          while (it.hasNext()) {
              StackElement st = it.next();
--            if (st.type == START_TXN) {
++            if (Objects.equals(st.type, START_TXN)) {
                  if (st.ref == null) {
                      it.remove();
                  } else {
@@@ -943,7 -943,7 +936,7 @@@
          Iterator<StackElement> it = _stack.iterator();
          while (it.hasNext()) {
              StackElement se = it.next();
--            if (se.type == START_TXN && se.ref == sp) {
++            if (Objects.equals(se.type, START_TXN) && se.ref == sp) {
                  return true;
              }
          }
@@@ -960,7 -960,7 +953,7 @@@
          Iterator<StackElement> it = _stack.iterator();
          while (it.hasNext()) {
              StackElement se = it.next();
--            if (se.type == START_TXN) {
++            if (Objects.equals(se.type, START_TXN)) {
                  it.remove();
                  if (se.ref == sp) {
                      return;
@@@ -993,7 -993,7 +986,7 @@@
  
      @Override
      protected void finalize() throws Throwable {
--        if (!(_conn == null && (_stack == null || _stack.size() == 0))) {
++        if (!(_conn == null && (_stack == null || _stack.isEmpty()))) {
              assert (false) : "Oh Alex oh alex...something is wrong with how 
we're doing this";
              LOGGER.error("Something went wrong that a transaction is orphaned 
before db connection is closed");
              cleanup();
@@@ -1052,11 -1052,11 +1045,11 @@@
      @SuppressWarnings({"rawtypes", "unchecked"})
      public static void initDataSource(Properties dbProps) {
          try {
--            if (dbProps.size() == 0)
++            if (dbProps.isEmpty())
                  return;
  
--            s_dbHAEnabled = 
Boolean.valueOf(dbProps.getProperty("db.ha.enabled"));
--            LOGGER.info("Is Data Base High Availiability enabled? Ans : " + 
s_dbHAEnabled);
++            s_dbHAEnabled = 
Boolean.parseBoolean(dbProps.getProperty("db.ha.enabled"));
++            LOGGER.info("Is Data Base High Availiability enabled? Ans : {}", 
s_dbHAEnabled);
              String loadBalanceStrategy = 
dbProps.getProperty("db.ha.loadBalanceStrategy");
              // FIXME:  If params are missing...default them????
              final Integer cloudMaxActive = 
parseNumber(dbProps.getProperty("db.cloud.maxActive"), Integer.class);
@@@ -1082,7 -1082,7 +1075,7 @@@
              } else if 
(cloudIsolationLevel.equalsIgnoreCase("readuncommitted")) {
                  isolationLevel = Connection.TRANSACTION_READ_UNCOMMITTED;
              } else {
--                LOGGER.warn("Unknown isolation level " + cloudIsolationLevel 
+ ".  Using read uncommitted");
++                LOGGER.warn("Unknown isolation level {}.  Using read 
uncommitted", cloudIsolationLevel);
              }
  
              final boolean cloudTestOnBorrow = 
Boolean.parseBoolean(dbProps.getProperty("db.cloud.testOnBorrow"));
@@@ -1190,16 -1190,16 +1183,16 @@@
              driver = dbProps.getProperty(String.format("db.%s.driver", 
schema));
              connectionUri = getPropertiesAndBuildConnectionUri(dbProps, 
loadBalanceStrategy, driver, useSSL, schema);
          } else {
--            LOGGER.warn(String.format("db.%s.uri was set, ignoring the 
following properties for schema %s of db.properties: [host, port, name, driver, 
autoReconnect, url.params,"
++            LOGGER.warn("db.{}.uri was set, ignoring the following properties 
for schema {} of db.properties: [host, port, name, driver, autoReconnect, 
url.params,"
                      + " replicas, ha.loadBalanceStrategy, ha.enable, 
failOverReadOnly, reconnectAtTxEnd, autoReconnectForPools, 
secondsBeforeRetrySource, queriesBeforeRetrySource, "
--                    + "initialTimeout].", schema, schema));
++                    + "initialTimeout].", schema, schema);
  
              String[] splitUri = propertyUri.split(":");
              driver = String.format("%s:%s", splitUri[0], splitUri[1]);
  
              connectionUri = propertyUri;
          }
--        LOGGER.info(String.format("Using the following URI to connect to %s 
database [%s].", schema, connectionUri));
++        LOGGER.info("Using the following URI to connect to {} database 
[{}].", schema, connectionUri);
          return new Pair<>(connectionUri, driver);
      }
  
@@@ -1215,7 -1215,7 +1208,7 @@@
          if (s_dbHAEnabled) {
              dbHaParams = getDBHAParams(schema, dbProps);
              replicas = dbProps.getProperty(String.format("db.%s.replicas", 
schema));
--            LOGGER.info(String.format("The replicas configured for %s data 
base are %s.", schema, replicas));
++            LOGGER.info("The replicas configured for {} data base are {}.", 
schema, replicas);
          }
  
          return buildConnectionUri(loadBalanceStrategy, driver, useSSL, host, 
replicas, port, dbName, autoReconnect, urlParams, dbHaParams);
@@@ -1322,8 -1322,8 +1315,7 @@@
          config.addDataSourceProperty("elideSetAutoCommits", "true");
          config.addDataSourceProperty("maintainTimeStats", "false");
  
--        HikariDataSource dataSource = new HikariDataSource(config);
--        return dataSource;
++        return new HikariDataSource(config);
      }
  
      private static DataSource createDbcpDataSource(String uri, String 
username, String password,
@@@ -1411,19 -1411,19 +1403,19 @@@
  
      private static String getDBHAParams(String dbName, Properties dbProps) {
          StringBuilder sb = new StringBuilder();
--        sb.append("failOverReadOnly=" + dbProps.getProperty("db." + dbName + 
".failOverReadOnly"));
--        sb.append("&").append("reconnectAtTxEnd=" + dbProps.getProperty("db." 
+ dbName + ".reconnectAtTxEnd"));
--        sb.append("&").append("autoReconnectForPools=" + 
dbProps.getProperty("db." + dbName + ".autoReconnectForPools"));
--        sb.append("&").append("secondsBeforeRetrySource=" + 
dbProps.getProperty("db." + dbName + ".secondsBeforeRetrySource"));
--        sb.append("&").append("queriesBeforeRetrySource=" + 
dbProps.getProperty("db." + dbName + ".queriesBeforeRetrySource"));
--        sb.append("&").append("initialTimeout=" + dbProps.getProperty("db." + 
dbName + ".initialTimeout"));
++        sb.append("failOverReadOnly=").append(dbProps.getProperty("db." + 
dbName + ".failOverReadOnly"));
++        
sb.append("&").append("reconnectAtTxEnd=").append(dbProps.getProperty("db." + 
dbName + ".reconnectAtTxEnd"));
++        
sb.append("&").append("autoReconnectForPools=").append(dbProps.getProperty("db."
 + dbName + ".autoReconnectForPools"));
++        
sb.append("&").append("secondsBeforeRetrySource=").append(dbProps.getProperty("db."
 + dbName + ".secondsBeforeRetrySource"));
++        
sb.append("&").append("queriesBeforeRetrySource=").append(dbProps.getProperty("db."
 + dbName + ".queriesBeforeRetrySource"));
++        
sb.append("&").append("initialTimeout=").append(dbProps.getProperty("db." + 
dbName + ".initialTimeout"));
          return sb.toString();
      }
  
      /**
       * Used for unit testing primarily
       *
--     * @param conn
++     * @param conn connection to use
       */
      protected void setConnection(Connection conn) {
          _conn = conn;
@@@ -1433,7 -1433,7 +1425,7 @@@
       * Receives a list of {@link PreparedStatement} and quietly closes all of 
them, which
       * triggers also closing their dependent objects, like a {@link ResultSet}
       *
--     * @param pstmt2Close
++     * @param pstmt2Close list of PreparedStatement to close
       */
      public static void closePstmts(List<PreparedStatement> pstmt2Close) {
          for (PreparedStatement pstmt : pstmt2Close) {


Reply via email to