Adds stacktrace to the logged warning in onPersistRejected() (#24263)

Fixes #24133: Switch to log.error from log.warning and add a stacktrace in onPersistRejected()
This commit is contained in:
Denys Zadorozhnyi 2018-01-11 12:52:38 +02:00 committed by Arnout Engelen
parent 7ce494b262
commit f1de21950d

View file

@ -4,18 +4,18 @@
package akka.persistence
import java.util.concurrent.atomic.AtomicInteger
import java.util.UUID
import java.util.concurrent.atomic.AtomicInteger
import scala.collection.immutable
import scala.util.control.NonFatal
import akka.actor.{ StashOverflowException, DeadLetter, ActorCell }
import akka.actor.{ ActorCell, DeadLetter, StashOverflowException }
import akka.annotation.InternalApi
import akka.dispatch.Envelope
import akka.event.{ Logging, LoggingAdapter }
import akka.util.Helpers.ConfigOps
import akka.event.Logging
import akka.event.LoggingAdapter
import scala.collection.immutable
import scala.concurrent.duration.FiniteDuration
import scala.util.control.NonFatal
/**
* INTERNAL API
@ -44,10 +44,9 @@ private[persistence] object Eventsourced {
*/
private[persistence] trait Eventsourced extends Snapshotter with PersistenceStash
with PersistenceIdentity with PersistenceRecovery {
import JournalProtocol._
import SnapshotProtocol.LoadSnapshotResult
import SnapshotProtocol.LoadSnapshotFailed
import Eventsourced._
import JournalProtocol._
import SnapshotProtocol.{ LoadSnapshotFailed, LoadSnapshotResult }
{
val interfaces = getClass.getInterfaces
@ -153,14 +152,15 @@ private[persistence] trait Eventsourced extends Snapshotter with PersistenceStas
/**
* Called when the journal rejected `persist` of an event. The event was not
* stored. By default this method logs the problem as a warning, and the actor continues.
* stored. By default this method logs the problem as an error, and the actor continues.
* The callback handler that was passed to the `persist` method will not be invoked.
*
* @param cause failure cause
* @param event the event that was to be persisted
*/
protected def onPersistRejected(cause: Throwable, event: Any, seqNr: Long): Unit = {
log.warning(
log.error(
cause,
"Rejected to persist event type [{}] with sequence number [{}] for persistenceId [{}] due to [{}].",
event.getClass.getName, seqNr, persistenceId, cause.getMessage)
}