{"action":"created","comment":{"url":"https://api.github.com/repos/akka/akka/pulls/comments/39622577","id":39622577,"diff_hunk":"@@ -0,0 +1,181 @@\n+/**\n+ * Copyright (C) 2009-2015 Typesafe Inc. <http://www.typesafe.com>\n+ */\n+\n+package akka.persistence\n+\n+import akka.actor.ActorRef\n+import akka.persistence.journal.SteppingInmemJournal\n+import akka.testkit.ImplicitSender\n+import com.typesafe.config.Config\n+\n+import scala.concurrent.duration._\n+\n+object PersistentActorStashingSpec {\n+  final case class Cmd(data: Any)\n+  final case class Evt(data: Any)\n+\n+  abstract class ExamplePersistentActor(name: String) extends NamedPersistentActor(name) {\n+    var events: List[Any] = Nil\n+    var askedForDelete: Option[ActorRef] = None\n+\n+    val updateState: Receive = {\n+      case Evt(data)               ⇒ events = data :: events\n+      case d @ Some(ref: ActorRef) ⇒ askedForDelete = d.asInstanceOf[Some[ActorRef]]\n+    }\n+\n+    val commonBehavior: Receive = {\n+      case \"boom\"   ⇒ throw new TestException(\"boom\")\n+      case GetState ⇒ sender() ! events.reverse\n+    }\n+\n+    def receiveRecover = updateState\n+  }\n+\n+  class UserStashPersistentActor(name: String) extends ExamplePersistentActor(name) {\n+    var stashed = false\n+    val receiveCommand: Receive = {\n+      case Cmd(\"a\") ⇒ if (!stashed) { stash(); stashed = true } else sender() ! \"a\"\n+      case Cmd(\"b\") ⇒ persist(Evt(\"b\"))(evt ⇒ sender() ! evt.data)\n+      case Cmd(\"c\") ⇒ unstashAll(); sender() ! \"c\"\n+    }\n+  }\n+\n+  class UserStashManyPersistentActor(name: String) extends ExamplePersistentActor(name) {\n+    val receiveCommand: Receive = commonBehavior orElse {\n+      case Cmd(\"a\") ⇒ persist(Evt(\"a\")) { evt ⇒\n+        updateState(evt)\n+        context.become(processC)\n+      }\n+      case Cmd(\"b-1\") ⇒ persist(Evt(\"b-1\"))(updateState)\n+      case Cmd(\"b-2\") ⇒ persist(Evt(\"b-2\"))(updateState)\n+    }\n+\n+    val processC: Receive = {\n+      case Cmd(\"c\") ⇒\n+        persist(Evt(\"c\")) { evt ⇒\n+          updateState(evt)\n+          context.unbecome()\n+        }\n+        unstashAll()\n+      case other ⇒ stash()\n+    }\n+  }\n+\n+  class UserStashFailurePersistentActor(name: String) extends ExamplePersistentActor(name) {\n+    val receiveCommand: Receive = commonBehavior orElse {\n+      case Cmd(data) ⇒\n+        if (data == \"b-2\") throw new TestException(\"boom\")\n+        persist(Evt(data)) { event ⇒\n+          updateState(event)\n+          if (data == \"a\") context.become(otherCommandHandler)\n+        }\n+    }\n+\n+    val otherCommandHandler: Receive = {\n+      case Cmd(\"c\") ⇒\n+        persist(Evt(\"c\")) { event ⇒\n+          updateState(event)\n+          context.unbecome()\n+        }\n+        unstashAll()\n+      case other ⇒ stash()\n+    }\n+  }\n+\n+  class AsyncStashingPersistentActor(name: String) extends ExamplePersistentActor(name) {\n+    var stashed = false\n+    val receiveCommand: Receive = commonBehavior orElse {\n+      case Cmd(\"a\") ⇒ persistAsync(Evt(\"a\"))(updateState)\n+      case Cmd(\"b\") if !stashed ⇒","path":"akka-persistence/src/test/scala/akka/persistence/PersistentActorStashingSpec.scala","position":90,"original_position":90,"commit_id":"4a13dfe000f95ff261f7a8e11d376fc90213fab2","original_commit_id":"52972f915bf19dea3a3779baab53d477ada1dc69","user":{"login":"johanandren","id":666915,"avatar_url":"https://avatars.githubusercontent.com/u/666915?v=3","gravatar_id":"","url":"https://api.github.com/users/johanandren","html_url":"https://github.com/johanandren","followers_url":"https://api.github.com/users/johanandren/followers","following_url":"https://api.github.com/users/johanandren/following{/other_user}","gists_url":"https://api.github.com/users/johanandren/gists{/gist_id}","starred_url":"https://api.github.com/users/johanandren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johanandren/subscriptions","organizations_url":"https://api.github.com/users/johanandren/orgs","repos_url":"https://api.github.com/users/johanandren/repos","events_url":"https://api.github.com/users/johanandren/events{/privacy}","received_events_url":"https://api.github.com/users/johanandren/received_events","type":"User","site_admin":false},"body":"Some sbt plugin keeps line-breaking this for me every time I compile :(","created_at":"2015-09-16T12:24:07Z","updated_at":"2015-09-16T12:24:07Z","html_url":"https://github.com/akka/akka/pull/18478#discussion_r39622577","pull_request_url":"https://api.github.com/repos/akka/akka/pulls/18478","_links":{"self":{"href":"https://api.github.com/repos/akka/akka/pulls/comments/39622577"},"html":{"href":"https://github.com/akka/akka/pull/18478#discussion_r39622577"},"pull_request":{"href":"https://api.github.com/repos/akka/akka/pulls/18478"}}},"pull_request":{"url":"https://api.github.com/repos/akka/akka/pulls/18478","id":45045943,"html_url":"https://github.com/akka/akka/pull/18478","diff_url":"https://github.com/akka/akka/pull/18478.diff","patch_url":"https://github.com/akka/akka/pull/18478.patch","issue_url":"https://api.github.com/repos/akka/akka/issues/18478","number":18478,"state":"open","locked":false,"title":"=per #16528 improved persistent actor stash test coverage","user":{"login":"johanandren","id":666915,"avatar_url":"https://avatars.githubusercontent.com/u/666915?v=3","gravatar_id":"","url":"https://api.github.com/users/johanandren","html_url":"https://github.com/johanandren","followers_url":"https://api.github.com/users/johanandren/followers","following_url":"https://api.github.com/users/johanandren/following{/other_user}","gists_url":"https://api.github.com/users/johanandren/gists{/gist_id}","starred_url":"https://api.github.com/users/johanandren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johanandren/subscriptions","organizations_url":"https://api.github.com/users/johanandren/orgs","repos_url":"https://api.github.com/users/johanandren/repos","events_url":"https://api.github.com/users/johanandren/events{/privacy}","received_events_url":"https://api.github.com/users/johanandren/received_events","type":"User","site_admin":false},"body":"Additionally: New async write journal for tests SteppingInmemJournal allows to\r\ncontrol the async journal operations tightly from a test. Each journal\r\noperation requires a token which the test then can wait for consumption of.\r\n\r\nRefs #16528 ","created_at":"2015-09-15T13:02:11Z","updated_at":"2015-09-16T12:24:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"96dab8a89147eccfb9610c60535eaec03e7ac6ae","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/akka/akka/pulls/18478/commits","review_comments_url":"https://api.github.com/repos/akka/akka/pulls/18478/comments","review_comment_url":"https://api.github.com/repos/akka/akka/pulls/comments{/number}","comments_url":"https://api.github.com/repos/akka/akka/issues/18478/comments","statuses_url":"https://api.github.com/repos/akka/akka/statuses/4a13dfe000f95ff261f7a8e11d376fc90213fab2","head":{"label":"johanandren:wip-16528-better-persistent-actor-stashing-test-coverage-johanandren","ref":"wip-16528-better-persistent-actor-stashing-test-coverage-johanandren","sha":"4a13dfe000f95ff261f7a8e11d376fc90213fab2","user":{"login":"johanandren","id":666915,"avatar_url":"https://avatars.githubusercontent.com/u/666915?v=3","gravatar_id":"","url":"https://api.github.com/users/johanandren","html_url":"https://github.com/johanandren","followers_url":"https://api.github.com/users/johanandren/followers","following_url":"https://api.github.com/users/johanandren/following{/other_user}","gists_url":"https://api.github.com/users/johanandren/gists{/gist_id}","starred_url":"https://api.github.com/users/johanandren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johanandren/subscriptions","organizations_url":"https://api.github.com/users/johanandren/orgs","repos_url":"https://api.github.com/users/johanandren/repos","events_url":"https://api.github.com/users/johanandren/events{/privacy}","received_events_url":"https://api.github.com/users/johanandren/received_events","type":"User","site_admin":false},"repo":{"id":41662207,"name":"akka","full_name":"johanandren/akka","owner":{"login":"johanandren","id":666915,"avatar_url":"https://avatars.githubusercontent.com/u/666915?v=3","gravatar_id":"","url":"https://api.github.com/users/johanandren","html_url":"https://github.com/johanandren","followers_url":"https://api.github.com/users/johanandren/followers","following_url":"https://api.github.com/users/johanandren/following{/other_user}","gists_url":"https://api.github.com/users/johanandren/gists{/gist_id}","starred_url":"https://api.github.com/users/johanandren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johanandren/subscriptions","organizations_url":"https://api.github.com/users/johanandren/orgs","repos_url":"https://api.github.com/users/johanandren/repos","events_url":"https://api.github.com/users/johanandren/events{/privacy}","received_events_url":"https://api.github.com/users/johanandren/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/johanandren/akka","description":"Akka Project","fork":true,"url":"https://api.github.com/repos/johanandren/akka","forks_url":"https://api.github.com/repos/johanandren/akka/forks","keys_url":"https://api.github.com/repos/johanandren/akka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/johanandren/akka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/johanandren/akka/teams","hooks_url":"https://api.github.com/repos/johanandren/akka/hooks","issue_events_url":"https://api.github.com/repos/johanandren/akka/issues/events{/number}","events_url":"https://api.github.com/repos/johanandren/akka/events","assignees_url":"https://api.github.com/repos/johanandren/akka/assignees{/user}","branches_url":"https://api.github.com/repos/johanandren/akka/branches{/branch}","tags_url":"https://api.github.com/repos/johanandren/akka/tags","blobs_url":"https://api.github.com/repos/johanandren/akka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/johanandren/akka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/johanandren/akka/git/refs{/sha}","trees_url":"https://api.github.com/repos/johanandren/akka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/johanandren/akka/statuses/{sha}","languages_url":"https://api.github.com/repos/johanandren/akka/languages","stargazers_url":"https://api.github.com/repos/johanandren/akka/stargazers","contributors_url":"https://api.github.com/repos/johanandren/akka/contributors","subscribers_url":"https://api.github.com/repos/johanandren/akka/subscribers","subscription_url":"https://api.github.com/repos/johanandren/akka/subscription","commits_url":"https://api.github.com/repos/johanandren/akka/commits{/sha}","git_commits_url":"https://api.github.com/repos/johanandren/akka/git/commits{/sha}","comments_url":"https://api.github.com/repos/johanandren/akka/comments{/number}","issue_comment_url":"https://api.github.com/repos/johanandren/akka/issues/comments{/number}","contents_url":"https://api.github.com/repos/johanandren/akka/contents/{+path}","compare_url":"https://api.github.com/repos/johanandren/akka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/johanandren/akka/merges","archive_url":"https://api.github.com/repos/johanandren/akka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/johanandren/akka/downloads","issues_url":"https://api.github.com/repos/johanandren/akka/issues{/number}","pulls_url":"https://api.github.com/repos/johanandren/akka/pulls{/number}","milestones_url":"https://api.github.com/repos/johanandren/akka/milestones{/number}","notifications_url":"https://api.github.com/repos/johanandren/akka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/johanandren/akka/labels{/name}","releases_url":"https://api.github.com/repos/johanandren/akka/releases{/id}","created_at":"2015-08-31T07:37:07Z","updated_at":"2015-08-31T07:37:15Z","pushed_at":"2015-09-16T09:31:37Z","git_url":"git://github.com/johanandren/akka.git","ssh_url":"git@github.com:johanandren/akka.git","clone_url":"https://github.com/johanandren/akka.git","svn_url":"https://github.com/johanandren/akka","homepage":"http://akka.io","size":167635,"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":"2cd4866bab3b798206ff5ddb14c4749d80708617","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-09-16T07:06:40Z","pushed_at":"2015-09-16T11:39:50Z","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":269838,"stargazers_count":4453,"watchers_count":4453,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1316,"mirror_url":null,"open_issues_count":697,"forks":1316,"open_issues":697,"watchers":4453,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/akka/akka/pulls/18478"},"html":{"href":"https://github.com/akka/akka/pull/18478"},"issue":{"href":"https://api.github.com/repos/akka/akka/issues/18478"},"comments":{"href":"https://api.github.com/repos/akka/akka/issues/18478/comments"},"review_comments":{"href":"https://api.github.com/repos/akka/akka/pulls/18478/comments"},"review_comment":{"href":"https://api.github.com/repos/akka/akka/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/akka/akka/pulls/18478/commits"},"statuses":{"href":"https://api.github.com/repos/akka/akka/statuses/4a13dfe000f95ff261f7a8e11d376fc90213fab2"}}}}