Skip to content

Commit

Permalink
InputStream from StreamConverters.asInputStream respects read() contr…
Browse files Browse the repository at this point in the history
…act #21943 (#21954) (#21969)
  • Loading branch information
ktoso committed Dec 8, 2016
1 parent d4080a8 commit 8fe8e0d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ class InputStreamSinkSpec extends StreamSpec(UnboundedMailboxConfig) {

inputStream.close()
}

"read next byte as an int from InputStream" in assertAllStagesStopped {
val bytes = ByteString(0, 100, 200, 255)
val inputStream = Source.single(bytes).runWith(StreamConverters.asInputStream())
List.fill(5)(inputStream.read()) should ===(List(0, 100, 200, 255, -1))
inputStream.close()
}
}

"fail to materialize with zero sized input buffer" in {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private[akka] class InputStreamAdapter(
@scala.throws(classOf[IOException])
override def read(): Int = {
val a = Array[Byte](1)
if (read(a, 0, 1) != -1) a(0)
if (read(a, 0, 1) != -1) a(0) & 0xff
else -1
}

Expand Down

0 comments on commit 8fe8e0d

Please sign in to comment.