Stop isReady method always returning true 21/7121/6
authorDave Tucker <djt@redhat.com>
Fri, 16 May 2014 17:24:54 +0000 (18:24 +0100)
committerDave Tucker <djt@redhat.com>
Thu, 22 May 2014 13:42:09 +0000 (14:42 +0100)
The OvsdbClientImpl.isReady() method will always return true as the
schema variable is initialized when the class is created and an
instance of a list can never be null.

This commit implements the timeout in the ToDo and changes the logic
to check if the schema.isEmpty

Change-Id: I1d48fa56f5a93e227fc3b623d3405d07a1751972
Signed-off-by: Dave Tucker <djt@redhat.com>
library/src/main/java/org/opendaylight/ovsdb/lib/OvsDBClientImpl.java

index 7230d06ea6553901464600bf8e1f3a84b2eb64b0..5bbfab4d58aae70d455d936686563c3c6998e11c 100644 (file)
@@ -178,9 +178,15 @@ public class OvsDBClientImpl implements OvsDBClient {
     }
 
 
-    public boolean isReady(long timeout) {
-        //todo implement timeout
-        return null != schema;
+    public boolean isReady(int timeout) throws InterruptedException {
+        while (timeout > 0) {
+            if (!schema.isEmpty()) {
+                return true;
+            }
+            Thread.sleep(1000);
+            timeout--;
+        }
+        return false;
     }
 
     @Override