Github user JoshRosen commented on a diff in the pull request:
https://github.com/apache/spark/pull/2760#discussion_r18859056
--- Diff: core/src/test/java/org/apache/spark/JavaAPISuite.java ---
@@ -1308,6 +1306,111 @@ public void collectUnderlyingScalaRDD() {
Assert.assertEquals(data.size(), collected.length);
}
+ private static final class IdentityWithDelay<T> implements Function<T,
T> {
+
+ final int delayMillis;
+
+ IdentityWithDelay(int delayMillis) {
+ this.delayMillis = delayMillis;
+ }
+
+ @Override
+ public T call(T x) throws Exception {
+ Thread.sleep(delayMillis);
+ return x;
+ }
+ }
+
+ private static final class BuggyMapFunction<T> implements Function<T, T>
{
+
+ @Override
+ public T call(T x) throws Exception {
+ throw new IllegalStateException("Custom exception!");
+ }
+ }
+
+ @Test
+ public void collectAsync() throws Exception {
+ List<Integer> data = Arrays.asList(1, 2, 3, 4, 5);
+ JavaRDD<Integer> rdd = sc.parallelize(data, 1);
+ JavaFutureAction<List<Integer>> future =
+ rdd.map(new IdentityWithDelay<Integer>(200)).collectAsync();
+ Assert.assertFalse(future.isCancelled());
--- End diff --
I was just matching the style of the nearby code, although I agree that the
static import is less verbose.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]