From 88e013b99b5f5d3df5ca816e7e313c0a79fa05d1 Mon Sep 17 00:00:00 2001 From: Konrad Malawski Date: Wed, 15 Apr 2015 17:47:09 +0200 Subject: [PATCH 1/2] =str #16608 adds section in readme explaining null is illegal --- akka-docs-dev/rst/java/stream-flows-and-basics.rst | 5 +++++ akka-docs-dev/rst/scala/stream-flows-and-basics.rst | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/akka-docs-dev/rst/java/stream-flows-and-basics.rst b/akka-docs-dev/rst/java/stream-flows-and-basics.rst index 2e8f4db9e2..b76b6a0351 100644 --- a/akka-docs-dev/rst/java/stream-flows-and-basics.rst +++ b/akka-docs-dev/rst/java/stream-flows-and-basics.rst @@ -104,6 +104,11 @@ There are various ways to wire up different parts of a stream, the following exa .. includecode:: ../../../akka-samples/akka-docs-java-lambda/src/test/java/docs/stream/FlowDocTest.java#flow-connecting +Illegal stream elements +^^^^^^^^^^^^^^^^^^^^^^^ +In accordance to the Reactive Streams specification (`Rule 2.13 `_) +Akka Streams do not allow ``null`` to be passed through the stream as an element. In case you want to model the concept +of absence of a value we recommend using ``akka.japi.Option`` (for Java 6 and 7) or ``java.util.Optional`` which is available since Java 8. .. _back-pressure-explained-java: diff --git a/akka-docs-dev/rst/scala/stream-flows-and-basics.rst b/akka-docs-dev/rst/scala/stream-flows-and-basics.rst index b604e8f4a5..8d835ed922 100644 --- a/akka-docs-dev/rst/scala/stream-flows-and-basics.rst +++ b/akka-docs-dev/rst/scala/stream-flows-and-basics.rst @@ -108,6 +108,11 @@ There are various ways to wire up different parts of a stream, the following exa .. includecode:: code/docs/stream/FlowDocSpec.scala#flow-connecting +Illegal stream elements +^^^^^^^^^^^^^^^^^^^^^^^ +In accordance to the Reactive Streams specification (`Rule 2.13 `_) +Akka Streams do not allow ``null`` to be passed through the stream as an element. In case you want to model the concept +of absence of a value we recommend using ``scala.Option`` or ``scala.util.Either``. .. _back-pressure-explained-scala: From 38638e42e4ccf66d6d6bccf2649517ca03581209 Mon Sep 17 00:00:00 2001 From: Konrad Malawski Date: Wed, 15 Apr 2015 17:41:41 +0200 Subject: [PATCH 2/2] =str #16608 adds scaladoc about null in col returned from mapConcat --- akka-stream/src/main/scala/akka/stream/javadsl/Flow.scala | 3 +++ akka-stream/src/main/scala/akka/stream/javadsl/Source.scala | 3 +++ akka-stream/src/main/scala/akka/stream/scaladsl/Flow.scala | 3 +++ 3 files changed, 9 insertions(+) diff --git a/akka-stream/src/main/scala/akka/stream/javadsl/Flow.scala b/akka-stream/src/main/scala/akka/stream/javadsl/Flow.scala index ed417609cf..0598ba0c81 100644 --- a/akka-stream/src/main/scala/akka/stream/javadsl/Flow.scala +++ b/akka-stream/src/main/scala/akka/stream/javadsl/Flow.scala @@ -154,6 +154,9 @@ class Flow[-In, +Out, +Mat](delegate: scaladsl.Flow[In, Out, Mat]) extends Graph /** * Transform each input element into a sequence of output elements that is * then flattened into the output stream. + * + * The returned list MUST NOT contain `null` values, + * as they are illegal as stream elements - according to the Reactive Streams specification. */ def mapConcat[T](f: japi.Function[Out, java.util.List[T]]): javadsl.Flow[In, T, Mat] = new Flow(delegate.mapConcat(elem ⇒ Util.immutableSeq(f.apply(elem)))) diff --git a/akka-stream/src/main/scala/akka/stream/javadsl/Source.scala b/akka-stream/src/main/scala/akka/stream/javadsl/Source.scala index 21e7d114c5..688752d060 100644 --- a/akka-stream/src/main/scala/akka/stream/javadsl/Source.scala +++ b/akka-stream/src/main/scala/akka/stream/javadsl/Source.scala @@ -292,6 +292,9 @@ class Source[+Out, +Mat](delegate: scaladsl.Source[Out, Mat]) extends Graph[Sour /** * Transform each input element into a sequence of output elements that is * then flattened into the output stream. + * + * The returned list MUST NOT contain `null` values, + * as they are illegal as stream elements - according to the Reactive Streams specification. */ def mapConcat[T](f: japi.Function[Out, java.util.List[T]]): javadsl.Source[T, Mat] = new Source(delegate.mapConcat(elem ⇒ Util.immutableSeq(f.apply(elem)))) diff --git a/akka-stream/src/main/scala/akka/stream/scaladsl/Flow.scala b/akka-stream/src/main/scala/akka/stream/scaladsl/Flow.scala index f8badfa779..a6911b35f9 100644 --- a/akka-stream/src/main/scala/akka/stream/scaladsl/Flow.scala +++ b/akka-stream/src/main/scala/akka/stream/scaladsl/Flow.scala @@ -336,6 +336,9 @@ trait FlowOps[+Out, +Mat] { /** * Transform each input element into a sequence of output elements that is * then flattened into the output stream. + * + * The returned sequence MUST NOT contain `null` values, + * as they are illegal as stream elements - according to the Reactive Streams specification. */ def mapConcat[T](f: Out ⇒ immutable.Seq[T]): Repr[T, Mat] = andThen(MapConcat(f.asInstanceOf[Any ⇒ immutable.Seq[Any]]))