Copilot commented on code in PR #11772:
URL: https://github.com/apache/cloudstack/pull/11772#discussion_r2418840380


##########
plugins/backup/veeam/src/main/java/org/apache/cloudstack/backup/veeam/VeeamClient.java:
##########
@@ -366,7 +366,9 @@ private boolean checkTaskStatus(final HttpResponse 
response) throws IOException
      * that is used to wait for the restore to complete before throwing a 
{@link CloudRuntimeException}.
      */
     protected void checkIfRestoreSessionFinished(String type, String path) 
throws IOException {
-        for (int j = 0; j < restoreTimeout; j++) {
+        long startTime = System.currentTimeMillis();
+        long timeoutMs = restoreTimeout * 1000L;
+        if (System.currentTimeMillis() - startTime < timeoutMs) {

Review Comment:
   The logic is incomplete - there's no timeout exception being thrown when the 
time limit is exceeded. The original for-loop would eventually exit and throw 
an exception, but this implementation will exit silently without any timeout 
handling.



##########
plugins/backup/veeam/src/main/java/org/apache/cloudstack/backup/veeam/VeeamClient.java:
##########
@@ -366,7 +366,9 @@ private boolean checkTaskStatus(final HttpResponse 
response) throws IOException
      * that is used to wait for the restore to complete before throwing a 
{@link CloudRuntimeException}.
      */
     protected void checkIfRestoreSessionFinished(String type, String path) 
throws IOException {
-        for (int j = 0; j < restoreTimeout; j++) {
+        long startTime = System.currentTimeMillis();
+        long timeoutMs = restoreTimeout * 1000L;
+        if (System.currentTimeMillis() - startTime < timeoutMs) {

Review Comment:
   The condition should use a while loop instead of an if statement. Currently, 
this will only check once and exit immediately if the timeout hasn't been 
reached, rather than continuously polling until timeout.
   ```suggestion
           while (System.currentTimeMillis() - startTime < timeoutMs) {
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to