if (bodyCapture instanceof LatchBodyCapture) {
try {
((LatchBodyCapture<?>) bodyCapture).getLatch().await(time,
timeUnit);
} catch (InterruptedException e) {
throw new ClientDriverInternalException("Interrupted waiting for capture", e);
}
} else {
long waitUntil = System.currentTimeMillis() + timeUnit.toMillis(time);
while (waitUntil > System.currentTimeMillis()) {
if (bodyCapture.getContent() != null) {
break;
}
try {
Thread.sleep(500);
} catch (InterruptedException e) {
throw new ClientDriverInternalException("Interrupted waiting for capture", e);
}
}
}
}