{"action":"created","comment":{"url":"https://api.github.com/repos/akka/akka/pulls/comments/55859774","id":55859774,"diff_hunk":"@@ -59,38 +59,82 @@ private[akka] final case class TakeWhile[T](p: T ⇒ Boolean, decider: Supervisi\n /**\n  * INTERNAL API\n  */\n-private[akka] final case class DropWhile[T](p: T ⇒ Boolean, decider: Supervision.Decider) extends PushStage[T, T] {\n+private[stream] final case class DropWhile[T](p: T ⇒ Boolean) extends GraphStage[FlowShape[T, T]] {\n+  val in = Inlet[T](\"DropWhile.in\")\n+  val out = Outlet[T](\"DropWhile.out\")\n+  override val shape = FlowShape(in, out)\n+  override def initialAttributes: Attributes = DefaultAttributes.dropWhile\n   var taking = false\n \n-  override def onPush(elem: T, ctx: Context[T]): SyncDirective =\n-    if (taking || !p(elem)) {\n-      taking = true\n-      ctx.push(elem)\n-    } else {\n-      ctx.pull()\n+  def createLogic(inheritedAttributes: Attributes) = new SupervisionedGraphStageLogic(inheritedAttributes, shape) with InHandler with OutHandler {\n+    override def onPush(): Unit = execute(() ⇒ {\n+      val el = grab(in)\n+      if (taking || !p(el)) {\n+        taking = true\n+        push(out, el)\n+      } else\n+        pull(in)\n+    })\n+\n+    override def onResume(t: Throwable): Unit = if (!hasBeenPulled(in)) pull(in)\n+    override def onRestart(t: Throwable): Unit = onResume(t)\n+\n+    override def onPull(): Unit = pull(in)\n+    setHandlers(in, out, this)\n+  }\n+  override def toString = \"DropWhile\"\n+}\n+\n+/**\n+  * INTERNAL API\n+  */\n+abstract private[stream] class SupervisionedGraphStageLogic(inheritedAttributes: Attributes, shape: Shape) extends GraphStageLogic(shape) {\n+  val decider = inheritedAttributes.get[SupervisionStrategy].map(_.decider).getOrElse(Supervision.stoppingDecider)\n+  def execute(f: () ⇒ Unit): Unit =\n+    try { f() } catch {\n+      case NonFatal(ex) ⇒ decider(ex) match {\n+        case Supervision.Stop    ⇒ onStop(ex)\n+        case Supervision.Resume  ⇒ onResume(ex)\n+        case Supervision.Restart ⇒ onRestart(ex)\n+      }\n     }\n \n-  override def decide(t: Throwable): Supervision.Directive = decider(t)\n+  def onResume(t: Throwable): Unit\n+  def onStop(t: Throwable): Unit = failStage(t)\n+  def onRestart(t: Throwable): Unit = onResume(t)\n }\n \n-private[akka] object Collect {\n+private[stream] object Collect {\n   // Cached function that can be used with PartialFunction.applyOrElse to ensure that A) the guard is only applied once,\n   // and the caller can check the returned value with Collect.notApplied to query whether the PF was applied or not.\n   // Prior art: https://github.com/scala/scala/blob/v2.11.4/src/library/scala/collection/immutable/List.scala#L458\n   final val NotApplied: Any ⇒ Any = _ ⇒ Collect.NotApplied\n }\n \n-private[akka] final case class Collect[In, Out](pf: PartialFunction[In, Out], decider: Supervision.Decider) extends PushStage[In, Out] {\n-\n-  import Collect.NotApplied\n+/**\n+ * INTERNAL API\n+ */\n+private[stream] final case class Collect[In, Out](pf: PartialFunction[In, Out]) extends GraphStage[FlowShape[In, Out]] {\n+  val in = Inlet[In](\"Collect.in\")\n+  val out = Outlet[Out](\"Collect.out\")\n+  override val shape = FlowShape(in, out)\n+  override def initialAttributes: Attributes = DefaultAttributes.collect\n \n-  override def onPush(elem: In, ctx: Context[Out]): SyncDirective =\n-    pf.applyOrElse(elem, NotApplied) match {\n-      case NotApplied             ⇒ ctx.pull()\n-      case result: Out @unchecked ⇒ ctx.push(result)\n-    }\n+  def createLogic(inheritedAttributes: Attributes) = new SupervisionedGraphStageLogic(inheritedAttributes, shape) with InHandler with OutHandler {\n+    import Collect.NotApplied\n+    override def onPush(): Unit =\n+      execute(() ⇒ {\n+        pf.applyOrElse(grab(in), NotApplied) match {\n+          case NotApplied             ⇒ pull(in)\n+          case result: Out @unchecked ⇒ push(out, result)\n+        }\n+      })\n \n-  override def decide(t: Throwable): Supervision.Directive = decider(t)\n+    override def onResume(t: Throwable): Unit = if (!hasBeenPulled(in)) pull(in)\n+    override def onPull(): Unit = pull(in)","path":"akka-stream/src/main/scala/akka/stream/impl/fusing/Ops.scala","position":94,"original_position":94,"commit_id":"1dad5c7587ac3ae6cd130cad6924fd253b5c2001","original_commit_id":"1dad5c7587ac3ae6cd130cad6924fd253b5c2001","user":{"login":"hepin1989","id":501740,"avatar_url":"https://avatars.githubusercontent.com/u/501740?v=3","gravatar_id":"","url":"https://api.github.com/users/hepin1989","html_url":"https://github.com/hepin1989","followers_url":"https://api.github.com/users/hepin1989/followers","following_url":"https://api.github.com/users/hepin1989/following{/other_user}","gists_url":"https://api.github.com/users/hepin1989/gists{/gist_id}","starred_url":"https://api.github.com/users/hepin1989/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hepin1989/subscriptions","organizations_url":"https://api.github.com/users/hepin1989/orgs","repos_url":"https://api.github.com/users/hepin1989/repos","events_url":"https://api.github.com/users/hepin1989/events{/privacy}","received_events_url":"https://api.github.com/users/hepin1989/received_events","type":"User","site_admin":false},"body":"eg:\r\n```scala\r\nabstract private[stream] class SupervisedPushPullGraphStageLogic[-In, +Out](inheritedAttributes: Attributes, shape: FlowShape[In, Out])\r\n  extends SupervisionedGraphStageLogic(inheritedAttributes, shape) with InHandler with OutHandler {\r\n  setHandlers(shape.in, shape.out, this)\r\n}\r\n\r\nabstract private[stream] class SupervisedPushGraphStageLogic[-In, +Out](inheritedAttributes: Attributes, shape: FlowShape[In, Out])\r\n  extends SupervisedPushPullGraphStageLogic(inheritedAttributes, shape) {\r\n  override def onPull() = pull(shape.in)\r\n}\r\n```","created_at":"2016-03-11T17:23:29Z","updated_at":"2016-03-11T17:23:29Z","html_url":"https://github.com/akka/akka/pull/19990#discussion_r55859774","pull_request_url":"https://api.github.com/repos/akka/akka/pulls/19990","_links":{"self":{"href":"https://api.github.com/repos/akka/akka/pulls/comments/55859774"},"html":{"href":"https://github.com/akka/akka/pull/19990#discussion_r55859774"},"pull_request":{"href":"https://api.github.com/repos/akka/akka/pulls/19990"}}},"pull_request":{"url":"https://api.github.com/repos/akka/akka/pulls/19990","id":62330550,"html_url":"https://github.com/akka/akka/pull/19990","diff_url":"https://github.com/akka/akka/pull/19990.diff","patch_url":"https://github.com/akka/akka/pull/19990.patch","issue_url":"https://api.github.com/repos/akka/akka/issues/19990","number":19990,"state":"open","locked":false,"title":"19834 replace collect with graph stage","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":"also added generalized class for stage logic to encapsulate supervision catching logic\r\nRef #19834","created_at":"2016-03-10T02:31:26Z","updated_at":"2016-03-11T17:23:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a1c8d1f8623c5073aa0dfdea7ec2c6ac0957c88e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/akka/akka/pulls/19990/commits","review_comments_url":"https://api.github.com/repos/akka/akka/pulls/19990/comments","review_comment_url":"https://api.github.com/repos/akka/akka/pulls/comments{/number}","comments_url":"https://api.github.com/repos/akka/akka/issues/19990/comments","statuses_url":"https://api.github.com/repos/akka/akka/statuses/1dad5c7587ac3ae6cd130cad6924fd253b5c2001","head":{"label":"agolubev:19834-replace-collect-with-GraphStage","ref":"19834-replace-collect-with-GraphStage","sha":"1dad5c7587ac3ae6cd130cad6924fd253b5c2001","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}","deployments_url":"https://api.github.com/repos/agolubev/akka/deployments","created_at":"2015-05-13T19:39:33Z","updated_at":"2016-01-15T22:47:18Z","pushed_at":"2016-03-11T01:18:22Z","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":177425,"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:master","ref":"master","sha":"87113f9b143203149f8014177c5bd2521a1fd77e","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}","deployments_url":"https://api.github.com/repos/akka/akka/deployments","created_at":"2009-02-16T12:51:54Z","updated_at":"2016-03-11T16:06:44Z","pushed_at":"2016-03-11T16:30:02Z","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":187007,"stargazers_count":5217,"watchers_count":5217,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1600,"mirror_url":null,"open_issues_count":818,"forks":1600,"open_issues":818,"watchers":5217,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/akka/akka/pulls/19990"},"html":{"href":"https://github.com/akka/akka/pull/19990"},"issue":{"href":"https://api.github.com/repos/akka/akka/issues/19990"},"comments":{"href":"https://api.github.com/repos/akka/akka/issues/19990/comments"},"review_comments":{"href":"https://api.github.com/repos/akka/akka/pulls/19990/comments"},"review_comment":{"href":"https://api.github.com/repos/akka/akka/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/akka/akka/pulls/19990/commits"},"statuses":{"href":"https://api.github.com/repos/akka/akka/statuses/1dad5c7587ac3ae6cd130cad6924fd253b5c2001"}}}}