一段时间后,AKKA停止记录堆栈跟踪

时间:2015-06-03 15:51:14

标签: java playframework akka slf4j

我对Akka和Play 2.3(Java)有一个非常奇怪的问题。

我有很多演员都有非常标准的slf4J日志记录:

public abstract class ScheduledJob extends UntypedActor {
    protected final LoggingAdapter logger = Logging.getLogger(getContext().system(), this);

我的akka​​.conf看起来像这样

akka {
         loggers = ["akka.event.slf4j.Slf4jLogger"]
         loglevel = "DEBUG"
                actor {
                  default-dispatcher = {
                     fork-join-executor {
                     parallelism-factor = 4.0
                     parallelism-max = 200
                   }
                 }
               }
          }

我的错误看起来像这样:

[2015-06-02 11:25:37,772] - [ERROR] - from akka.actor.OneForOneStrategy at [akka://application/user/distributor-anchor/router]
null
java.lang.NullPointerException: null
        at services.analytics.thirdparty.ServiceImpl.track(ServiceImpl.java:175) ~[tf-rest-play.tf-rest-play-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
        at actor.services.analytics.DistributorActor.lambda$track$20(DistributorActor.java:146) ~[tf-rest-play.tf-rest-play-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
        at actor.services.analytics.DistributorActor$$Lambda$25/1308315289.accept(Unknown Source) ~[na:na]
        at java.util.Iterator.forEachRemaining(Iterator.java:116) ~[na:1.8.0_40]
        at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) ~[na:1.8.0_40]
        at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580) ~[na:1.8.0_40]
        at actor.services.analytics.DistributorActor.track(DistributorActor.java:145) ~[tf-rest-play.tf-rest-play-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
        at actor.services.analytics.DistributorActor.onReceive(DistributorActor.java:54) ~[tf-rest-play.tf-rest-play-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
        at akka.actor.UntypedActor$$anonfun$receive$1.applyOrElse(UntypedActor.scala:167) ~[com.typesafe.akka.akka-actor_2.10-2.3.4.jar:na]
        at akka.actor.Actor$class.aroundReceive(Actor.scala:465) ~[com.typesafe.akka.akka-actor_2.10-2.3.4.jar:na]
        at akka.actor.UntypedActor.aroundReceive(UntypedActor.scala:97) ~[com.typesafe.akka.akka-actor_2.10-2.3.4.jar:na]
        at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516) [com.typesafe.akka.akka-actor_2.10-2.3.4.jar:na]
        at akka.actor.ActorCell.invoke(ActorCell.scala:487) [com.typesafe.akka.akka-actor_2.10-2.3.4.jar:na]
        at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238) [com.typesafe.akka.akka-actor_2.10-2.3.4.jar:na]
        at akka.dispatch.Mailbox.run(Mailbox.scala:220) [com.typesafe.akka.akka-actor_2.10-2.3.4.jar:na]
        at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393) [com.typesafe.akka.akka-actor_2.10-2.3.4.jar:na]
        at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [org.scala-lang.scala-library-2.10.4.jar:na]
        at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [org.scala-lang.scala-library-2.10.4.jar:na]
        at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [org.scala-lang.scala-library-2.10.4.jar:na]
        at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) [org.scala-lang.scala-library-2.10.4.jar:na]

在不确定(8-24小时)的时间后,堆栈跟踪消失,并且输出相同的错误:

[2015-06-02 17:33:43,338] - [ERROR] - from akka.actor.OneForOneStrategy at [akka://application/user/distributor-anchor/router]
 null
 java.lang.NullPointerException: null

我100%确定上述两个错误是相同的(即它们是由相同的条件引起并在代码中的相同位置抛出)但无法确定堆栈跟踪从日志中消失的原因一段时间后输出。重新启动修复了问题(直到它最终回来)。

1 个答案:

答案 0 :(得分:3)

这是JVM的正常行为,您可以使用-XX:-OmitStackTraceInFastThrow关闭预分配异常的使用。