twitter / storehaus

Storehaus is a library that makes it easy to work with asynchronous key value stores
Apache License 2.0
464 stars 86 forks source link

Fix for issue 287 #288

Closed pankajroark closed 8 years ago

pankajroark commented 8 years ago

The root cause is that pattern match on a stream evaluates both head and tail. So in: def findT(pred: T => Boolean): Future[T] = futures match { case Stream.Empty => Future.exception(new RuntimeException("Empty iterator in FutureOps.find")) case last #:: Stream.Empty => last case next #:: rest => next.filter(pred).rescue { case _: Throwable => find(rest)(pred) } }

when the second case is hit i.e. " case last #:: Stream.Empty => last" it evaluates the tail, resulting in a call to the second store.

Fixed by eliminating the use of pattern match.

pankajroark commented 8 years ago

Not sure why test failed on travis-ci for scala 2.11.7. The same test passes for me locally with scala 2.11.7.

BenFradet commented 8 years ago

Yeah, it's not related to your changes, I have the same problem in #286

johnynek commented 8 years ago

Thanks @pankajroark test failure seems totally unrelated, so I'll merge.