diff --git a/azure-client-runtime/src/main/java/com/microsoft/azure/PagedList.java b/azure-client-runtime/src/main/java/com/microsoft/azure/PagedList.java index 4f966acbcf3d0..8db10337d9898 100644 --- a/azure-client-runtime/src/main/java/com/microsoft/azure/PagedList.java +++ b/azure-client-runtime/src/main/java/com/microsoft/azure/PagedList.java @@ -47,7 +47,10 @@ public PagedList() { */ public PagedList(Page page) { this(); - items.addAll(page.getItems()); + List retrievedItems = page.getItems(); + if (retrievedItems != null && retrievedItems.size() != 0) { + items.addAll(retrievedItems); + } nextPageLink = page.getNextPageLink(); currentPage = page; } @@ -138,14 +141,17 @@ public boolean hasNext() { public E next() { if (!itemsListItr.hasNext()) { if (!hasNextPage()) { - throw new NoSuchElementException(); + throw new NoSuchElementException(); } else { int size = items.size(); loadNextPage(); itemsListItr = items.listIterator(size); } } - return itemsListItr.next(); + if (itemsListItr.hasNext()) { + return itemsListItr.next(); + } + return null; } @Override diff --git a/azure-client-runtime/src/main/java/com/microsoft/azure/TaskGroup.java b/azure-client-runtime/src/main/java/com/microsoft/azure/TaskGroup.java index 75722a494feac..ada803b38c3e8 100644 --- a/azure-client-runtime/src/main/java/com/microsoft/azure/TaskGroup.java +++ b/azure-client-runtime/src/main/java/com/microsoft/azure/TaskGroup.java @@ -47,15 +47,6 @@ public interface TaskGroup> { */ void prepare(); - /** - * Executes the tasks in the group. - *

- * the order of execution of tasks ensure that a task gets selected for execution only after - * the execution of all the tasks it depends on - * @throws Exception the exception - */ - void execute() throws Exception; - /** * Executes the tasks in the group asynchronously. * diff --git a/azure-client-runtime/src/main/java/com/microsoft/azure/TaskGroupBase.java b/azure-client-runtime/src/main/java/com/microsoft/azure/TaskGroupBase.java index 46fe8d0f179f2..747f0273fa7d6 100644 --- a/azure-client-runtime/src/main/java/com/microsoft/azure/TaskGroupBase.java +++ b/azure-client-runtime/src/main/java/com/microsoft/azure/TaskGroupBase.java @@ -58,31 +58,8 @@ public void prepare() { } } - @Override - public void execute() throws Exception { - DAGNode nextNode = dag.getNext(); - while (nextNode != null) { - nextNode.data().execute(); - this.dag().reportedCompleted(nextNode); - nextNode = dag.getNext(); - } - } - @Override public Observable executeAsync() { - return executeReadyTasksAsync().last(); - } - - @Override - public T taskResult(String taskId) { - return dag.getNodeData(taskId).result(); - } - - /** - * Executes all runnable tasks, a task is runnable when all the tasks its depends - * on are finished running. - */ - private Observable executeReadyTasksAsync() { DAGNode nextNode = dag.getNext(); final List> observables = new ArrayList<>(); while (nextNode != null) { @@ -95,7 +72,7 @@ public Observable call(T t) { if (dag().isRootNode(thisNode)) { return Observable.just(t); } else { - return executeReadyTasksAsync(); + return executeAsync(); } } })); @@ -103,4 +80,9 @@ public Observable call(T t) { } return Observable.merge(observables); } + + @Override + public T taskResult(String taskId) { + return dag.getNodeData(taskId).result(); + } } diff --git a/azure-client-runtime/src/main/java/com/microsoft/azure/TaskItem.java b/azure-client-runtime/src/main/java/com/microsoft/azure/TaskItem.java index df9bf4b04a941..dd24167c89681 100644 --- a/azure-client-runtime/src/main/java/com/microsoft/azure/TaskItem.java +++ b/azure-client-runtime/src/main/java/com/microsoft/azure/TaskItem.java @@ -20,15 +20,6 @@ public interface TaskItem { */ U result(); - /** - * Executes the task. - *

- * once executed the result will be available through result getter - * - * @throws Exception exception - */ - void execute() throws Exception; - /** * Executes the task asynchronously. *