Simplify recoveryTime computation 69/82469/2
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 7 Jun 2019 22:44:58 +0000 (00:44 +0200)
committerRobert Varga <nite@hq.sk>
Tue, 11 Jun 2019 15:07:01 +0000 (15:07 +0000)
Stopwatch.stop() returns self, take advantage of that to shorted
the code to compute the formatting string. Also drop toString()
call, as it is implied by string concat.

Change-Id: I4fa645e42fc38b5f9f0775d986fd17aa693725b1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 49f3024ee0a621729e31279f8b2d46051fc003f1)

opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorRecoverySupport.java

index 564d64ca2d3fd5575489613de714406da848e703..d94fd293be594da1c687b2b57101b4c70dbc8786 100644 (file)
@@ -241,11 +241,12 @@ class RaftActorRecoverySupport {
             endCurrentLogRecoveryBatch();
         }
 
-        String recoveryTime = "";
+        final String recoveryTime;
         if (recoveryTimer != null) {
-            recoveryTimer.stop();
-            recoveryTime = " in " + recoveryTimer.toString();
+            recoveryTime = " in " + recoveryTimer.stop();
             recoveryTimer = null;
+        } else {
+            recoveryTime = "";
         }
 
         log.info("{}: Recovery completed {} - Switching actor to Follower - last log index = {}, last log term = {}, "