You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/02/20 22:09:21 UTC

[GitHub] rabbah closed pull request #3311: Bump default retry timeout to 50 milliseconds.

rabbah closed pull request #3311: Bump default retry timeout to 50 milliseconds.
URL: https://github.com/apache/incubator-openwhisk/pull/3311
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/common/scala/src/main/scala/whisk/utils/Retry.scala b/common/scala/src/main/scala/whisk/utils/Retry.scala
index 9a759ddf84..e5f7c2219b 100644
--- a/common/scala/src/main/scala/whisk/utils/Retry.scala
+++ b/common/scala/src/main/scala/whisk/utils/Retry.scala
@@ -17,12 +17,7 @@
 
 package whisk.utils
 
-import scala.concurrent.duration.Duration
-import scala.concurrent.duration.DurationInt
-import scala.util.Failure
-import scala.util.Success
-import scala.util.Try
-import scala.language.postfixOps
+import scala.concurrent.duration._
 
 object retry {
 
@@ -34,21 +29,17 @@ object retry {
    * @param N the maximum number of times to apply fn, must be >= 1
    * @param waitBeforeRetry an option specifying duration to wait before retrying method, will not wait if none given
    * @return the result of fn iff it is successful
-   * @throws exception from fn (or an illegal argument exception if N is < 1)
+   * @throws Throwable exception from fn (or an illegal argument exception if N is < 1)
    */
-  def apply[T](fn: => T, N: Int = 3, waitBeforeRetry: Option[Duration] = Some(1 millisecond)): T = {
+  def apply[T](fn: => T, N: Int = 3, waitBeforeRetry: Option[Duration] = Some(50.milliseconds)): T = {
     require(N >= 1, "maximum number of fn applications must be greater than 1")
-    waitBeforeRetry map { t =>
-      Thread.sleep(t.toMillis)
-    } // initial wait if any
-    Try { fn } match {
-      case Success(r) => r
+    waitBeforeRetry.foreach(t => Thread.sleep(t.toMillis)) // initial wait if any
+
+    try fn
+    catch {
       case _ if N > 1 =>
-        waitBeforeRetry map { t =>
-          Thread.sleep(t.toMillis)
-        }
+        waitBeforeRetry.foreach(t => Thread.sleep(t.toMillis))
         retry(fn, N - 1, waitBeforeRetry)
-      case Failure(t) => throw t
     }
   }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services