nvazquez commented on code in PR #7558: URL: https://github.com/apache/cloudstack/pull/7558#discussion_r1205319874
########## engine/schema/src/main/java/com/cloud/vm/dao/ConsoleSessionDaoImpl.java: ########## @@ -60,9 +65,20 @@ public int expungeSessionsOlderThanDate(Date date) { @Override public void acquireSession(String sessionUuid) { + TransactionLegacy txn = TransactionLegacy.currentTxn(); ConsoleSessionVO consoleSessionVO = findByUuid(sessionUuid); - consoleSessionVO.setAcquired(new Date()); - update(consoleSessionVO.getId(), consoleSessionVO); + long consoleSessionId = consoleSessionVO.getId(); + try { + txn.start(); + PreparedStatement preparedStatement = txn.prepareAutoCloseStatement(ACQUIRE_CONSOLE_SESSION); + preparedStatement.setDate(1, new java.sql.Date(-1L)); + preparedStatement.setLong(2, consoleSessionId); + preparedStatement.executeUpdate(); + txn.commit(); + } catch (Exception e) { + txn.rollback(); + LOGGER.warn(String.format("Failed acquiring console session id = %s: %s", consoleSessionId, e.getMessage()), e); + } Review Comment: I've refactored after @shwstppr's suggestion -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@cloudstack.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org