Skip to content

Commit 28b80ce

Browse files
authored
Merge pull request #21 from Corsinvest/fix/wait-task-thread-sleep
Fix busy-waiting in waitForTaskToFinish - bump to 9.1.2
2 parents 0fc0375 + 5ec151b commit 28b80ce

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<!-- === PROJECT INFO === -->
99
<groupId>it.corsinvest.proxmoxve</groupId>
1010
<artifactId>cv4pve-api-java</artifactId>
11-
<version>9.1.1</version>
11+
<version>9.1.2</version>
1212
<packaging>jar</packaging>
1313

1414
<name>cv4pve-api-java</name>

src/main/java/it/corsinvest/proxmoxve/api/PveClientBase.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -579,11 +579,13 @@ public boolean waitForTaskToFinish(String task, long wait, long timeOut) {
579579
}
580580

581581
var timeStart = System.currentTimeMillis();
582-
var waitTime = System.currentTimeMillis();
583582
while (isRunning && (System.currentTimeMillis() - timeStart) < timeOut) {
584-
if ((System.currentTimeMillis() - waitTime) >= wait) {
585-
waitTime = System.currentTimeMillis();
586-
isRunning = taskIsRunning(task);
583+
isRunning = taskIsRunning(task);
584+
try {
585+
Thread.sleep(wait);
586+
} catch (InterruptedException e) {
587+
Thread.currentThread().interrupt();
588+
break;
587589
}
588590
}
589591

0 commit comments

Comments
 (0)