This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-clients.git
commit 81a05069721380d65eeaf587ee33b289cb910c5b Author: Valentin Olteanu <[email protected]> AuthorDate: Tue Mar 6 10:29:32 2018 +0100 SLING-7169 - track time waited in Polling --- .../apache/sling/testing/clients/util/poller/Polling.java | 13 +++++++++++++ .../sling/testing/clients/util/poller/package-info.java | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/sling/testing/clients/util/poller/Polling.java b/src/main/java/org/apache/sling/testing/clients/util/poller/Polling.java index f40a610..f08deeb 100644 --- a/src/main/java/org/apache/sling/testing/clients/util/poller/Polling.java +++ b/src/main/java/org/apache/sling/testing/clients/util/poller/Polling.java @@ -41,6 +41,11 @@ public class Polling implements Callable<Boolean> { protected Exception lastException; /** + * Counter for total waiting time + */ + protected long waited; + + /** * Default constructor to be used in subclasses that override the {@link #call()} method. * Should not be used directly on {@code Polling} instances, but only on extended classes. * If used directly to get a {@code Polling} instance, executing {@link #poll(long timeout, long delay)} @@ -49,6 +54,7 @@ public class Polling implements Callable<Boolean> { public Polling() { this.c = null; this.lastException = null; + this.waited = 0; } /** @@ -59,6 +65,7 @@ public class Polling implements Callable<Boolean> { public Polling(Callable<Boolean> c) { this.c = c; this.lastException = null; + this.waited = 0; } /** @@ -105,6 +112,7 @@ public class Polling implements Callable<Boolean> { try { boolean success = call(); if (success) { + waited = System.currentTimeMillis() - start; return; } } catch (Exception e) { @@ -113,9 +121,14 @@ public class Polling implements Callable<Boolean> { Thread.sleep(delay); } while (System.currentTimeMillis() < start + effectiveTimeout); + waited = System.currentTimeMillis() - start; throw new TimeoutException(String.format(message(), effectiveTimeout, delay)); } + public long getWaited() { + return waited; + } + /** * Returns the string to be used in the {@code TimeoutException}, if needed. * The string is passed to {@code String.format(message(), timeout, delay)}, so it can be a format diff --git a/src/main/java/org/apache/sling/testing/clients/util/poller/package-info.java b/src/main/java/org/apache/sling/testing/clients/util/poller/package-info.java index 4d723bb..ec084db 100644 --- a/src/main/java/org/apache/sling/testing/clients/util/poller/package-info.java +++ b/src/main/java/org/apache/sling/testing/clients/util/poller/package-info.java @@ -17,7 +17,7 @@ * under the License. */ -@Version("1.1.0") +@Version("1.2.0") package org.apache.sling.testing.clients.util.poller; import org.osgi.annotation.versioning.Version; -- To stop receiving notification emails like this one, please contact [email protected].
