{"action":"created","issue":{"url":"https://api.github.com/repos/akka/akka/issues/21652","repository_url":"https://api.github.com/repos/akka/akka","labels_url":"https://api.github.com/repos/akka/akka/issues/21652/labels{/name}","comments_url":"https://api.github.com/repos/akka/akka/issues/21652/comments","events_url":"https://api.github.com/repos/akka/akka/issues/21652/events","html_url":"https://github.com/akka/akka/issues/21652","id":182201885,"number":21652,"title":"Change in ContextAware in 2.4.11","user":{"login":"durban","id":1568978,"avatar_url":"https://avatars.githubusercontent.com/u/1568978?v=3","gravatar_id":"","url":"https://api.github.com/users/durban","html_url":"https://github.com/durban","followers_url":"https://api.github.com/users/durban/followers","following_url":"https://api.github.com/users/durban/following{/other_user}","gists_url":"https://api.github.com/users/durban/gists{/gist_id}","starred_url":"https://api.github.com/users/durban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/durban/subscriptions","organizations_url":"https://api.github.com/users/durban/orgs","repos_url":"https://api.github.com/users/durban/repos","events_url":"https://api.github.com/users/durban/events{/privacy}","received_events_url":"https://api.github.com/users/durban/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/akka/akka/labels/t:typed","name":"t:typed","color":"eeeeee"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-11T08:19:28Z","updated_at":"2016-10-22T13:24:37Z","closed_at":null,"body":"There seems to be a change in the implementation of `akka.typed.ScalaDSL.ContextAware` in 2.4.11. It's unclear to me whether this was intentional. Code similar to [this](https://github.com/durban/akka-typed-examples/blob/35f03e204e4055a2583cc5459dd62880290857a6/src/main/scala/com/example/actors/CtxAware.scala), used to work before. In 2.4.11 it throws the following exception:\r\n```\r\n[ERROR] [10/11/2016 10:05:26.536] [boo-akka.actor.default-dispatcher-14] [akka://boo/user/b] ContextAware must receive PreStart as first message (got Msg(akka.typed.adapter.ActorContextAdapter@1f5884e9,2))\r\njava.lang.IllegalStateException: ContextAware must receive PreStart as first message (got Msg(akka.typed.adapter.ActorContextAdapter@1f5884e9,2))\r\n        at akka.typed.ScalaDSL$$anonfun$ContextAware$1.apply(ScalaDSL.scala:444)\r\n        at akka.typed.ScalaDSL$$anonfun$ContextAware$1.apply(ScalaDSL.scala:442)\r\n        at akka.typed.ScalaDSL$FullTotal.message(ScalaDSL.scala:178)\r\n        at akka.typed.adapter.ActorAdapter$$anonfun$receive$1.applyOrElse(ActorAdapter.scala:32)\r\n        at akka.actor.Actor$class.aroundReceive(Actor.scala:484)\r\n        at akka.typed.adapter.ActorAdapter.aroundReceive(ActorAdapter.scala:9)                                                                                                               \r\n        at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526)                                                                                                                          \r\n        at akka.actor.ActorCell.invoke(ActorCell.scala:495)                                                                                                                                  \r\n        at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257)                                                                                                                           \r\n        at akka.dispatch.Mailbox.run(Mailbox.scala:224)                                                                                                                                      \r\n        at akka.dispatch.Mailbox.exec(Mailbox.scala:234)                                                                                                                                     \r\n        at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)\r\n        at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)\r\n        at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)\r\n        at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)\r\n```\r\n\r\nNote, that it seems to be possible to work around this exception like [this](https://github.com/durban/akka-typed-examples/blob/54ec06077671cdf330baee6bafcf25a4c4a2ebdf/src/main/scala/com/example/actors/CtxAware2.scala). Is this how `ContextAware` is supposed to be used now?"},"comment":{"url":"https://api.github.com/repos/akka/akka/issues/comments/255528220","html_url":"https://github.com/akka/akka/issues/21652#issuecomment-255528220","issue_url":"https://api.github.com/repos/akka/akka/issues/21652","id":255528220,"user":{"login":"rkuhn","id":470469,"avatar_url":"https://avatars.githubusercontent.com/u/470469?v=3","gravatar_id":"","url":"https://api.github.com/users/rkuhn","html_url":"https://github.com/rkuhn","followers_url":"https://api.github.com/users/rkuhn/followers","following_url":"https://api.github.com/users/rkuhn/following{/other_user}","gists_url":"https://api.github.com/users/rkuhn/gists{/gist_id}","starred_url":"https://api.github.com/users/rkuhn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rkuhn/subscriptions","organizations_url":"https://api.github.com/users/rkuhn/orgs","repos_url":"https://api.github.com/users/rkuhn/repos","events_url":"https://api.github.com/users/rkuhn/events{/privacy}","received_events_url":"https://api.github.com/users/rkuhn/received_events","type":"User","site_admin":false},"created_at":"2016-10-22T13:24:37Z","updated_at":"2016-10-22T13:24:37Z","body":"Sorry for the delay, which is in part due to my inability to find a clear reasoning. The change was made to be more consistent in that behavior decorators need to be properly “started”, there is a new facility `Behavior.preStart` to do this correctly. On the other hand I am uncertain of the value of this consistency beyond, well, being consistent.\r\n\r\nWhat I like about the situation is that it forced you to make your implementation more allocation efficient by reusing and not always re-extracting the ActorContext. So I’m leaning towards just leaving it as is, perhaps with improved documentation.\r\n\r\nWhat do others think?"}}
{"actor":{"display_login":"rkuhn"}}