Skip to content

Commit b1205e8

Browse files
RUBY-320: Cassandra::Future.all([]).join hangs forever
1 parent be24f8e commit b1205e8

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# master
22
Bug Fixes:
33
* [RUBY-319](https://datastax-oss.atlassian.net/browse/RUBY-319) Support reading decimals in scientific notation with positive exponent.
4+
* [RUBY-320](https://datastax-oss.atlassian.net/browse/RUBY-320) Cassandra::Future.all([]).join hangs forever
45

56
# 3.2.1
67

lib/cassandra/future.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,13 @@ def promise
204204
end
205205

206206
def all(*futures)
207-
futures = Array(futures.first) if futures.one?
207+
# May get called with varargs or an array of futures. In the latter case,
208+
# the first element in futures is the array of futures. Promote it.
209+
futures = Array(futures.first) if futures.one?
210+
211+
# Special case where there are no futures to aggregate.
212+
return Value.new([]) if futures.empty?
213+
208214
monitor = Monitor.new
209215
promise = Promise.new(@executor)
210216
remaining = futures.length

spec/cassandra/future_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ module Listeners
6969
futures << Future.error(RuntimeError.new("something happened"))
7070
expect { Future.all(futures).get }.to raise_error("something happened")
7171
end
72+
73+
it 'trivially succeeds when there are no futures' do
74+
expect(Future.all.get).to eq([])
75+
expect(Future.all([]).get).to eq([])
76+
end
7277
end
7378

7479
describe('#get') do

0 commit comments

Comments
 (0)