EDU-646 NoSuchElementException in TaskNavigationActions
authorliana.bakradze <liana.bakradze@jetbrains.com>
Sun, 26 Jun 2016 10:16:44 +0000 (13:16 +0300)
committerliana.bakradze <liana.bakradze@jetbrains.com>
Sun, 26 Jun 2016 10:16:44 +0000 (13:16 +0300)
python/educational-core/student/src/com/jetbrains/edu/learning/StudyUtils.java

index 69542b448629b48302bbef42e7ae472c8c12acba..020dbc27f58e4842b925beeeb10385ecfd272a7c 100644 (file)
@@ -67,6 +67,7 @@ import java.awt.*;
 import java.io.*;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Iterator;
 import java.util.List;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
@@ -115,7 +116,11 @@ public class StudyUtils {
   }
 
   public static <T> T getFirst(@NotNull final Iterable<T> container) {
-    return container.iterator().next();
+    Iterator<T> iterator = container.iterator();
+    if (!iterator.hasNext()) {
+      return null;
+    }
+    return iterator.next();
   }
 
   public static boolean indexIsValid(int index, @NotNull final Collection collection) {