VMware Cloud Community
PeterABC123
Contributor
Contributor

Java SDK

Hi everyone,

I'm currently developing an application using the vCD Java SDK to create and control vApps, and I'm seeing some strange behaviour in the waitForTask() function.

Basically we do something like this

Vapp vapp = Vapp.getVappByReference(vcloudclient, vappRef);

vapp.suspend();

vapp = Vapp.getVappByReference(vcloudclient, vappRef);     //update vApp reference

List<Task> tasks = vapp.getTasks();

for (Task task : tasks) {

  System.out.println(task.getReference().getHref());

  task.waitForTask(0);

}

This can be done in one command: vapp.suspend().waitForTask(0) but for the purpose of debugging we're doing it the long way.

The issue is that sometimes (seemingly randomly) waitForTask() will not return at all and halts the thread indefinitely because of the zero time out.  However when I use the REST API I can see that the task already has 'status="success"'.

curl -i -k -H "Accept:application/*+xml;version=5.1" -H "x-vcloud-authorization: $token" -X GET https://vcd.example/api/task/32487f06-9af8-4a88-8f83-49ac4eee311c

Has anyone encountered this kind of issue before?

Thanks in advance for any help given.

Peter

0 Kudos
0 Replies