diff --git a/rxlib/src/main/java/org/rx/core/EventBus.java b/rxlib/src/main/java/org/rx/core/EventBus.java index 8289d287..bd5d0b43 100644 --- a/rxlib/src/main/java/org/rx/core/EventBus.java +++ b/rxlib/src/main/java/org/rx/core/EventBus.java @@ -89,7 +89,7 @@ Map, Set>> findAllSubscribers(Object listener) { Map, Set>> methodsInListener = new HashMap<>(); for (Method method : Linq.from(Reflects.getMethodMap(listener instanceof Class ? (Class) listener : listener.getClass()).values()).selectMany(p -> p).where(p -> p.isAnnotationPresent(Subscribe.class) && !p.isSynthetic())) { if (method.getParameterCount() != 1) { - throw new InvalidException("Subscriber method %s has @Subscribe annotation must have exactly 1 parameter.", method); + throw new InvalidException("Subscriber method {} has @Subscribe annotation must have exactly 1 parameter.", method); } Class eventType = method.getParameterTypes()[0]; methodsInListener.computeIfAbsent(eventType, k -> new HashSet<>()).add(Tuple.of(listener, method)); diff --git a/rxlib/src/main/java/org/rx/core/FluentWait.java b/rxlib/src/main/java/org/rx/core/FluentWait.java index 16fc2f45..cd8b3074 100644 --- a/rxlib/src/main/java/org/rx/core/FluentWait.java +++ b/rxlib/src/main/java/org/rx/core/FluentWait.java @@ -42,6 +42,7 @@ public static FluentWait polling(long timeoutMillis, long intervalMillis, Bi private BiFunc resultFunc; private List> ignoredExceptions; private String message; + private boolean initialDelay; private long retryMillis = TIMEOUT_INFINITE; private BiAction retryFunc; private boolean retryOnStart; @@ -63,6 +64,11 @@ public synchronized FluentWait withMessage(String message) { return this; } + public synchronized FluentWait withInitialDelay() { + this.initialDelay = true; + return this; + } + public FluentWait retryEvery(long interval, BiAction retryFunc) { return retryEvery(interval, retryFunc, false); } @@ -135,6 +141,9 @@ public synchronized T await(@NonNull BiFunc resultFunc) throw boolean doRetry = retryCount > TIMEOUT_INFINITE; Throwable cause; T result = null; + if (initialDelay) { + sleep(interval); + } do { try { if ((result = resultFunc.invoke(this)) != null) {