Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow Exceptions to propagate out of fold tasks CLJ-1058

Before this change, an java.lang.Exception thrown while processing by a
single task is caught and ignored. Infinite recursion comes from falling
out of the "if(tasks.size() == 1)" block into the following code that
splits multiple tasks.

This change adds a call to Util.sneakyThrow(e) in the catch block.

Demonstration of the problem, from Tom Jack:

user> (require '[clojure.core.reducers :as r])
nil
user> (r/fold (fn ([]) ([ret k v] (+ 3 "foo") ret))
              (into {} (map (juxt identity identity) (range 10000))))
StackOverflowError   clojure.lang.Numbers.add (Numbers.java:126)

Signed-off-by: Stuart Halloway <stu@cognitect.com>
  • Loading branch information...
commit 5cc167ad735de5d115e0f4b7158332ad4ef5726c 1 parent 6c318f5
@bruceadams bruceadams authored Stuart Halloway committed
Showing with 1 addition and 1 deletion.
  1. +1 −1  src/jvm/clojure/lang/PersistentHashMap.java
View
2  src/jvm/clojure/lang/PersistentHashMap.java
@@ -441,7 +441,7 @@ static public Object foldTasks(List<Callable> tasks, final IFn combinef,
}
catch(Exception e)
{
- //aargh
+ throw Util.sneakyThrow(e);
}
}

0 comments on commit 5cc167a

Please sign in to comment.
Something went wrong with that request. Please try again.