Merge pull request #17228 from akka/wip-16699-fixmes-patriknw
=str #16699 fix some FIXMEs
This commit is contained in:
commit
33919f683c
10 changed files with 29 additions and 37 deletions
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
package akka.stream.javadsl
|
||||
|
||||
import scala.collection.immutable
|
||||
import java.util.concurrent.Callable
|
||||
import akka.actor.{ Cancellable, ActorRef, Props }
|
||||
import akka.japi.Util
|
||||
|
|
@ -95,9 +96,21 @@ object Source {
|
|||
* Iterator, but every Subscriber directly attached to the Publisher of this
|
||||
* stream will see an individual flow of elements (always starting from the
|
||||
* beginning) regardless of when they subscribed.
|
||||
*
|
||||
* Make sure that the `Iterable` is immutable or at least not modified after
|
||||
* being used as a `Source`. Otherwise the stream may fail with
|
||||
* `ConcurrentModificationException` or other more subtle errors may occur.
|
||||
*/
|
||||
def from[O](iterable: java.lang.Iterable[O]): javadsl.Source[O, Unit] =
|
||||
new Source(scaladsl.Source(akka.stream.javadsl.japi.Util.immutableIterable(iterable)))
|
||||
def from[O](iterable: java.lang.Iterable[O]): javadsl.Source[O, Unit] = {
|
||||
// this adapter is not immutable if the the underlying java.lang.Iterable is modified
|
||||
// but there is not anything we can do to prevent that from happening.
|
||||
// ConcurrentModificationException will be thrown in some cases.
|
||||
val scalaIterable = new immutable.Iterable[O] {
|
||||
import collection.JavaConverters._
|
||||
override def iterator: Iterator[O] = iterable.iterator().asScala
|
||||
}
|
||||
new Source(scaladsl.Source(scalaIterable))
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a new `Source` from the given `Future`. The stream will consist of
|
||||
|
|
@ -366,7 +379,7 @@ class Source[+Out, +Mat](delegate: scaladsl.Source[Out, Mat]) extends Graph[Sour
|
|||
* @param n must be positive, and `d` must be greater than 0 seconds, otherwise [[IllegalArgumentException]] is thrown.
|
||||
*/
|
||||
def groupedWithin(n: Int, d: FiniteDuration): javadsl.Source[java.util.List[Out @uncheckedVariance], Mat] =
|
||||
new Source(delegate.groupedWithin(n, d).map(_.asJava)) // FIXME optimize to one step
|
||||
new Source(delegate.groupedWithin(n, d).map(_.asJava)) // TODO optimize to one step
|
||||
|
||||
/**
|
||||
* Discard the given number of elements at the beginning of the stream.
|
||||
|
|
@ -476,7 +489,7 @@ class Source[+Out, +Mat](delegate: scaladsl.Source[Out, Mat]) extends Graph[Sour
|
|||
* to consume only one of them.
|
||||
*/
|
||||
def groupBy[K](f: japi.Function[Out, K]): javadsl.Source[akka.japi.Pair[K, javadsl.Source[Out @uncheckedVariance, Unit]], Mat] =
|
||||
new Source(delegate.groupBy(f.apply).map { case (k, p) ⇒ akka.japi.Pair(k, p.asJava) }) // FIXME optimize to one step
|
||||
new Source(delegate.groupBy(f.apply).map { case (k, p) ⇒ akka.japi.Pair(k, p.asJava) }) // TODO optimize to one step
|
||||
|
||||
/**
|
||||
* This operation applies the given predicate to all incoming elements and
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue