Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LAFuture.collect crashes when futures are resolved out of order #1453

Merged
merged 1 commit into from
May 27, 2013

Conversation

tuhlmann
Copy link
Member

I'm using LAFuture.collect from Lift 3 Snapshot to collect 3 futures into one. It sometimes throws an IndexOutOfBoundsException at me.
The reason is this line:

val vals = new collection.mutable.ArrayBufferBox[T]

which defines the result array. Later, when future 2 is satisfied before future 1 it tries to insert it at a index that does not yet exist, thus throwing the exception.
The fix I found was to pad the array with Empty's and then later in the foreach write a Full into it.

Here's the repl that produces the exception:

scala> new collection.mutable.ArrayBufferInt
res0: scala.collection.mutable.ArrayBuffer[Int] = ArrayBuffer()

scala> res0.insert(2, 4)
java.lang.IndexOutOfBoundsException: 2

@ghost ghost assigned tuhlmann May 25, 2013
@tuhlmann
Copy link
Member Author

Any opinions?

@dpp
Copy link
Member

dpp commented May 27, 2013

Ship it

dpp added a commit that referenced this pull request May 27, 2013
LAFuture.collect crashes when futures are resolved out of order
@dpp dpp merged commit 6363f72 into master May 27, 2013
@dpp dpp deleted the uhl_issue_1453 branch May 27, 2013 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants