{"action":"created","comment":{"url":"https://api.github.com/repos/akka/akka/pulls/comments/41951582","id":41951582,"diff_hunk":"@@ -0,0 +1,135 @@\n+/**\n+ * Copyright (C) 2015 Typesafe Inc. <http://www.typesafe.com>\n+ */\n+package akka.stream.io\n+\n+import java.io.IOException\n+import java.util.concurrent.TimeoutException\n+\n+import akka.stream._\n+import akka.stream.scaladsl.Keep\n+import akka.stream.testkit.Utils._\n+import akka.stream.testkit._\n+import akka.stream.testkit.scaladsl.TestSink\n+import akka.util.ByteString\n+\n+import scala.concurrent.duration.Duration.Zero\n+import scala.concurrent.duration._\n+import scala.concurrent.{ Await, Future }\n+\n+class OutputStreamSourceSpec extends AkkaSpec(UnboundedMailboxConfig) {\n+  import system.dispatcher\n+\n+  val settings = ActorMaterializerSettings(system)\n+  implicit val materializer = ActorMaterializer(settings)\n+\n+  val timeout = 300.milliseconds\n+  val bytes = \"abc\".getBytes\n+  val byteString = ByteString(\"abc\")\n+\n+  def expectBlocked[T](f: Future[T]) =\n+    the[Exception] thrownBy Await.result(f, timeout) shouldBe a[TimeoutException]\n+\n+  def expectSuccess[T](f: Future[T], value: T) =\n+    Await.result(f, timeout) should be(value)\n+\n+  \"OutputStreamSource\" must {\n+    \"read bytes from OutputStream\" in assertAllStagesStopped {\n+      val (outputStream, probe) = OutputStreamSource().toMat(TestSink.probe[ByteString])(Keep.both).run\n+      val s = probe.expectSubscription()\n+\n+      outputStream.write(bytes)\n+      s.request(1)\n+      probe.expectNext(byteString)\n+      outputStream.close()\n+      probe.expectComplete()\n+      //Await.result(f, timeout) should be(3)\n+    }\n+\n+    \"block flush call until send all buffer to downstream\" in assertAllStagesStopped {\n+      val (outputStream, probe) = OutputStreamSource().toMat(TestSink.probe[ByteString])(Keep.both).run\n+      val s = probe.expectSubscription()\n+\n+      outputStream.write(bytes)\n+      val f = Future(outputStream.flush())\n+\n+      expectBlocked(f)\n+      probe.expectNoMsg(Zero)\n+\n+      s.request(1)\n+      expectSuccess(f, ())\n+      probe.expectNext(byteString)\n+\n+      outputStream.close()\n+      probe.expectComplete()\n+    }\n+\n+    \"not block flushes when buffer is empty\" in assertAllStagesStopped {\n+      val (outputStream, probe) = OutputStreamSource().toMat(TestSink.probe[ByteString])(Keep.both).run\n+      val s = probe.expectSubscription()\n+\n+      outputStream.write(bytes)\n+\n+      val f = Future(outputStream.flush())\n+      s.request(1)\n+      expectSuccess(f, ())\n+      probe.expectNext(byteString)\n+\n+      val f2 = Future(outputStream.flush())\n+      expectSuccess(f2, ())\n+\n+      outputStream.close()\n+      probe.expectComplete()\n+    }\n+\n+    \"block writes when buffer is full\" in assertAllStagesStopped {\n+      val (outputStream, probe) = OutputStreamSource().toMat(TestSink.probe[ByteString])(Keep.both).run\n+      val s = probe.expectSubscription()\n+\n+      //default max-input-buffer-size = 16","path":"akka-stream-tests/src/test/scala/akka/stream/io/OutputStreamSourceSpec.scala","position":89,"original_position":89,"commit_id":"811a98a1e9fe6903a585a8764b3b0e385299b6c1","original_commit_id":"811a98a1e9fe6903a585a8764b3b0e385299b6c1","user":{"login":"agolubev","id":461456,"avatar_url":"https://avatars.githubusercontent.com/u/461456?v=3","gravatar_id":"","url":"https://api.github.com/users/agolubev","html_url":"https://github.com/agolubev","followers_url":"https://api.github.com/users/agolubev/followers","following_url":"https://api.github.com/users/agolubev/following{/other_user}","gists_url":"https://api.github.com/users/agolubev/gists{/gist_id}","starred_url":"https://api.github.com/users/agolubev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agolubev/subscriptions","organizations_url":"https://api.github.com/users/agolubev/orgs","repos_url":"https://api.github.com/users/agolubev/repos","events_url":"https://api.github.com/users/agolubev/events{/privacy}","received_events_url":"https://api.github.com/users/agolubev/received_events","type":"User","site_admin":false},"body":"Ok, found example       \r\n```scala\r\nval p = SynchronousFileSource(testFile, chunkSize)\r\n        .withAttributes(bufferAttributes)\r\n        .runWith(Sink.publisher)\r\n```","created_at":"2015-10-14T03:22:45Z","updated_at":"2015-10-14T03:22:45Z","html_url":"https://github.com/akka/akka/pull/18707#discussion_r41951582","pull_request_url":"https://api.github.com/repos/akka/akka/pulls/18707","_links":{"self":{"href":"https://api.github.com/repos/akka/akka/pulls/comments/41951582"},"html":{"href":"https://github.com/akka/akka/pull/18707#discussion_r41951582"},"pull_request":{"href":"https://api.github.com/repos/akka/akka/pulls/18707"}}},"pull_request":{"url":"https://api.github.com/repos/akka/akka/pulls/18707","id":47385035,"html_url":"https://github.com/akka/akka/pull/18707","diff_url":"https://github.com/akka/akka/pull/18707.diff","patch_url":"https://github.com/akka/akka/pull/18707.patch","issue_url":"https://api.github.com/repos/akka/akka/issues/18707","number":18707,"state":"open","locked":false,"title":"Agolubev #17338 add output stream source graph stage based","user":{"login":"agolubev","id":461456,"avatar_url":"https://avatars.githubusercontent.com/u/461456?v=3","gravatar_id":"","url":"https://api.github.com/users/agolubev","html_url":"https://github.com/agolubev","followers_url":"https://api.github.com/users/agolubev/followers","following_url":"https://api.github.com/users/agolubev/following{/other_user}","gists_url":"https://api.github.com/users/agolubev/gists{/gist_id}","starred_url":"https://api.github.com/users/agolubev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agolubev/subscriptions","organizations_url":"https://api.github.com/users/agolubev/orgs","repos_url":"https://api.github.com/users/agolubev/repos","events_url":"https://api.github.com/users/agolubev/events{/privacy}","received_events_url":"https://api.github.com/users/agolubev/received_events","type":"User","site_admin":false},"body":"This is for ticket #17338. \r\nCurrent brunch implements OuputStreamSource with GraphStageWithMaterializedValue as @drewhk suggested (InsputStreamSink stays unchanged). First version is in PR #17995 and based on ActorPublisher/ActorSubscriber.\r\nPlease let me know if this approach is good enough to fix the ticket.\r\nCurrently one test javadsl/scaladsl is failed as in javadsl new apply method is missed (had to introduce scaladsl.SourceApply.apply with builder materializer type)\r\n","created_at":"2015-10-12T04:28:12Z","updated_at":"2015-10-14T03:22:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/akka/akka/pulls/18707/commits","review_comments_url":"https://api.github.com/repos/akka/akka/pulls/18707/comments","review_comment_url":"https://api.github.com/repos/akka/akka/pulls/comments{/number}","comments_url":"https://api.github.com/repos/akka/akka/issues/18707/comments","statuses_url":"https://api.github.com/repos/akka/akka/statuses/811a98a1e9fe6903a585a8764b3b0e385299b6c1","head":{"label":"agolubev:agolubev-#17338_add_OutputStreamSource_GraphStage_based","ref":"agolubev-#17338_add_OutputStreamSource_GraphStage_based","sha":"811a98a1e9fe6903a585a8764b3b0e385299b6c1","user":{"login":"agolubev","id":461456,"avatar_url":"https://avatars.githubusercontent.com/u/461456?v=3","gravatar_id":"","url":"https://api.github.com/users/agolubev","html_url":"https://github.com/agolubev","followers_url":"https://api.github.com/users/agolubev/followers","following_url":"https://api.github.com/users/agolubev/following{/other_user}","gists_url":"https://api.github.com/users/agolubev/gists{/gist_id}","starred_url":"https://api.github.com/users/agolubev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agolubev/subscriptions","organizations_url":"https://api.github.com/users/agolubev/orgs","repos_url":"https://api.github.com/users/agolubev/repos","events_url":"https://api.github.com/users/agolubev/events{/privacy}","received_events_url":"https://api.github.com/users/agolubev/received_events","type":"User","site_admin":false},"repo":{"id":35570392,"name":"akka","full_name":"agolubev/akka","owner":{"login":"agolubev","id":461456,"avatar_url":"https://avatars.githubusercontent.com/u/461456?v=3","gravatar_id":"","url":"https://api.github.com/users/agolubev","html_url":"https://github.com/agolubev","followers_url":"https://api.github.com/users/agolubev/followers","following_url":"https://api.github.com/users/agolubev/following{/other_user}","gists_url":"https://api.github.com/users/agolubev/gists{/gist_id}","starred_url":"https://api.github.com/users/agolubev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agolubev/subscriptions","organizations_url":"https://api.github.com/users/agolubev/orgs","repos_url":"https://api.github.com/users/agolubev/repos","events_url":"https://api.github.com/users/agolubev/events{/privacy}","received_events_url":"https://api.github.com/users/agolubev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/agolubev/akka","description":"Akka Project","fork":true,"url":"https://api.github.com/repos/agolubev/akka","forks_url":"https://api.github.com/repos/agolubev/akka/forks","keys_url":"https://api.github.com/repos/agolubev/akka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/agolubev/akka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/agolubev/akka/teams","hooks_url":"https://api.github.com/repos/agolubev/akka/hooks","issue_events_url":"https://api.github.com/repos/agolubev/akka/issues/events{/number}","events_url":"https://api.github.com/repos/agolubev/akka/events","assignees_url":"https://api.github.com/repos/agolubev/akka/assignees{/user}","branches_url":"https://api.github.com/repos/agolubev/akka/branches{/branch}","tags_url":"https://api.github.com/repos/agolubev/akka/tags","blobs_url":"https://api.github.com/repos/agolubev/akka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/agolubev/akka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/agolubev/akka/git/refs{/sha}","trees_url":"https://api.github.com/repos/agolubev/akka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/agolubev/akka/statuses/{sha}","languages_url":"https://api.github.com/repos/agolubev/akka/languages","stargazers_url":"https://api.github.com/repos/agolubev/akka/stargazers","contributors_url":"https://api.github.com/repos/agolubev/akka/contributors","subscribers_url":"https://api.github.com/repos/agolubev/akka/subscribers","subscription_url":"https://api.github.com/repos/agolubev/akka/subscription","commits_url":"https://api.github.com/repos/agolubev/akka/commits{/sha}","git_commits_url":"https://api.github.com/repos/agolubev/akka/git/commits{/sha}","comments_url":"https://api.github.com/repos/agolubev/akka/comments{/number}","issue_comment_url":"https://api.github.com/repos/agolubev/akka/issues/comments{/number}","contents_url":"https://api.github.com/repos/agolubev/akka/contents/{+path}","compare_url":"https://api.github.com/repos/agolubev/akka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/agolubev/akka/merges","archive_url":"https://api.github.com/repos/agolubev/akka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/agolubev/akka/downloads","issues_url":"https://api.github.com/repos/agolubev/akka/issues{/number}","pulls_url":"https://api.github.com/repos/agolubev/akka/pulls{/number}","milestones_url":"https://api.github.com/repos/agolubev/akka/milestones{/number}","notifications_url":"https://api.github.com/repos/agolubev/akka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/agolubev/akka/labels{/name}","releases_url":"https://api.github.com/repos/agolubev/akka/releases{/id}","created_at":"2015-05-13T19:39:33Z","updated_at":"2015-05-13T19:39:39Z","pushed_at":"2015-10-12T04:18:57Z","git_url":"git://github.com/agolubev/akka.git","ssh_url":"git@github.com:agolubev/akka.git","clone_url":"https://github.com/agolubev/akka.git","svn_url":"https://github.com/agolubev/akka","homepage":"http://akka.io","size":165787,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"akka:release-2.3-dev","ref":"release-2.3-dev","sha":"97622c22b151eeb230302aff6479780690b42b8d","user":{"login":"akka","id":1496237,"avatar_url":"https://avatars.githubusercontent.com/u/1496237?v=3","gravatar_id":"","url":"https://api.github.com/users/akka","html_url":"https://github.com/akka","followers_url":"https://api.github.com/users/akka/followers","following_url":"https://api.github.com/users/akka/following{/other_user}","gists_url":"https://api.github.com/users/akka/gists{/gist_id}","starred_url":"https://api.github.com/users/akka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akka/subscriptions","organizations_url":"https://api.github.com/users/akka/orgs","repos_url":"https://api.github.com/users/akka/repos","events_url":"https://api.github.com/users/akka/events{/privacy}","received_events_url":"https://api.github.com/users/akka/received_events","type":"Organization","site_admin":false},"repo":{"id":130013,"name":"akka","full_name":"akka/akka","owner":{"login":"akka","id":1496237,"avatar_url":"https://avatars.githubusercontent.com/u/1496237?v=3","gravatar_id":"","url":"https://api.github.com/users/akka","html_url":"https://github.com/akka","followers_url":"https://api.github.com/users/akka/followers","following_url":"https://api.github.com/users/akka/following{/other_user}","gists_url":"https://api.github.com/users/akka/gists{/gist_id}","starred_url":"https://api.github.com/users/akka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akka/subscriptions","organizations_url":"https://api.github.com/users/akka/orgs","repos_url":"https://api.github.com/users/akka/repos","events_url":"https://api.github.com/users/akka/events{/privacy}","received_events_url":"https://api.github.com/users/akka/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/akka/akka","description":"Akka Project","fork":false,"url":"https://api.github.com/repos/akka/akka","forks_url":"https://api.github.com/repos/akka/akka/forks","keys_url":"https://api.github.com/repos/akka/akka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akka/akka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akka/akka/teams","hooks_url":"https://api.github.com/repos/akka/akka/hooks","issue_events_url":"https://api.github.com/repos/akka/akka/issues/events{/number}","events_url":"https://api.github.com/repos/akka/akka/events","assignees_url":"https://api.github.com/repos/akka/akka/assignees{/user}","branches_url":"https://api.github.com/repos/akka/akka/branches{/branch}","tags_url":"https://api.github.com/repos/akka/akka/tags","blobs_url":"https://api.github.com/repos/akka/akka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akka/akka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akka/akka/git/refs{/sha}","trees_url":"https://api.github.com/repos/akka/akka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akka/akka/statuses/{sha}","languages_url":"https://api.github.com/repos/akka/akka/languages","stargazers_url":"https://api.github.com/repos/akka/akka/stargazers","contributors_url":"https://api.github.com/repos/akka/akka/contributors","subscribers_url":"https://api.github.com/repos/akka/akka/subscribers","subscription_url":"https://api.github.com/repos/akka/akka/subscription","commits_url":"https://api.github.com/repos/akka/akka/commits{/sha}","git_commits_url":"https://api.github.com/repos/akka/akka/git/commits{/sha}","comments_url":"https://api.github.com/repos/akka/akka/comments{/number}","issue_comment_url":"https://api.github.com/repos/akka/akka/issues/comments{/number}","contents_url":"https://api.github.com/repos/akka/akka/contents/{+path}","compare_url":"https://api.github.com/repos/akka/akka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akka/akka/merges","archive_url":"https://api.github.com/repos/akka/akka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akka/akka/downloads","issues_url":"https://api.github.com/repos/akka/akka/issues{/number}","pulls_url":"https://api.github.com/repos/akka/akka/pulls{/number}","milestones_url":"https://api.github.com/repos/akka/akka/milestones{/number}","notifications_url":"https://api.github.com/repos/akka/akka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akka/akka/labels{/name}","releases_url":"https://api.github.com/repos/akka/akka/releases{/id}","created_at":"2009-02-16T12:51:54Z","updated_at":"2015-10-14T01:34:58Z","pushed_at":"2015-10-13T20:45:08Z","git_url":"git://github.com/akka/akka.git","ssh_url":"git@github.com:akka/akka.git","clone_url":"https://github.com/akka/akka.git","svn_url":"https://github.com/akka/akka","homepage":"http://akka.io","size":271458,"stargazers_count":4566,"watchers_count":4566,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1356,"mirror_url":null,"open_issues_count":776,"forks":1356,"open_issues":776,"watchers":4566,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/akka/akka/pulls/18707"},"html":{"href":"https://github.com/akka/akka/pull/18707"},"issue":{"href":"https://api.github.com/repos/akka/akka/issues/18707"},"comments":{"href":"https://api.github.com/repos/akka/akka/issues/18707/comments"},"review_comments":{"href":"https://api.github.com/repos/akka/akka/pulls/18707/comments"},"review_comment":{"href":"https://api.github.com/repos/akka/akka/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/akka/akka/pulls/18707/commits"},"statuses":{"href":"https://api.github.com/repos/akka/akka/statuses/811a98a1e9fe6903a585a8764b3b0e385299b6c1"}}}}