diff --git a/akka-persistence/src/main/scala/akka/persistence/journal/leveldb/LeveldbJournal.scala b/akka-persistence/src/main/scala/akka/persistence/journal/leveldb/LeveldbJournal.scala index a6e8c3b3e2..75b932f45d 100644 --- a/akka-persistence/src/main/scala/akka/persistence/journal/leveldb/LeveldbJournal.scala +++ b/akka-persistence/src/main/scala/akka/persistence/journal/leveldb/LeveldbJournal.scala @@ -20,9 +20,15 @@ import com.typesafe.config.Config * * Journal backed by a local LevelDB store. For production use. */ -private[persistence] class LeveldbJournal(val config: Config) extends AsyncWriteJournal with LeveldbStore { +private[persistence] class LeveldbJournal(cfg: Config) extends AsyncWriteJournal with LeveldbStore { import LeveldbJournal._ + def this() = this(LeveldbStore.emptyConfig) + + override def prepareConfig: Config = + if (cfg ne LeveldbStore.emptyConfig) cfg + else context.system.settings.config.getConfig("akka.persistence.journal.leveldb") + override def receivePluginInternal: Receive = { case r @ ReplayTaggedMessages(fromSequenceNr, toSequenceNr, max, tag, replyTo) ⇒ import context.dispatcher diff --git a/akka-persistence/src/main/scala/akka/persistence/journal/leveldb/LeveldbStore.scala b/akka-persistence/src/main/scala/akka/persistence/journal/leveldb/LeveldbStore.scala index d9e0533d5b..d9b5d23a3e 100644 --- a/akka-persistence/src/main/scala/akka/persistence/journal/leveldb/LeveldbStore.scala +++ b/akka-persistence/src/main/scala/akka/persistence/journal/leveldb/LeveldbStore.scala @@ -6,25 +6,33 @@ package akka.persistence.journal.leveldb import java.io.File + import scala.collection.mutable import akka.actor._ import akka.persistence._ import akka.persistence.journal.WriteJournalBase import akka.serialization.SerializationExtension import org.iq80.leveldb._ + import scala.collection.immutable import scala.util._ import scala.concurrent.Future import scala.util.control.NonFatal import akka.persistence.journal.Tagged -import com.typesafe.config.Config +import com.typesafe.config.{ Config, ConfigFactory } + +private[persistence] object LeveldbStore { + val emptyConfig = ConfigFactory.empty() +} /** * INTERNAL API. */ private[persistence] trait LeveldbStore extends Actor with WriteJournalBase with LeveldbIdMapping with LeveldbRecovery { - val config: Config + def prepareConfig: Config + + val config: Config = prepareConfig val nativeLeveldb = config.getBoolean("native") val leveldbOptions = new Options().createIfMissing(true) diff --git a/akka-persistence/src/main/scala/akka/persistence/journal/leveldb/SharedLeveldbStore.scala b/akka-persistence/src/main/scala/akka/persistence/journal/leveldb/SharedLeveldbStore.scala index d4f260da50..9c695c89ad 100644 --- a/akka-persistence/src/main/scala/akka/persistence/journal/leveldb/SharedLeveldbStore.scala +++ b/akka-persistence/src/main/scala/akka/persistence/journal/leveldb/SharedLeveldbStore.scala @@ -18,10 +18,16 @@ import scala.concurrent.Future * set for each actor system that uses the store via `SharedLeveldbJournal.setStore`. The * shared LevelDB store is for testing only. */ -class SharedLeveldbStore(cfg: Config) extends { override val config = cfg.getConfig("store") } with LeveldbStore { +class SharedLeveldbStore(cfg: Config) extends LeveldbStore { import AsyncWriteTarget._ import context.dispatcher + def this() = this(LeveldbStore.emptyConfig) + + override def prepareConfig: Config = + if (cfg ne LeveldbStore.emptyConfig) cfg.getConfig("store") + else context.system.settings.config.getConfig("akka.persistence.journal.leveldb-shared.store") + def receive = { case WriteMessages(messages) ⇒ // TODO it would be nice to DRY this with AsyncWriteJournal, but this is using diff --git a/project/MiMa.scala b/project/MiMa.scala index 69a8fc038a..caf542f1f3 100644 --- a/project/MiMa.scala +++ b/project/MiMa.scala @@ -633,9 +633,8 @@ object MiMa extends AutoPlugin { ProblemFilters.exclude[DirectMissingMethodProblem]("akka.persistence.snapshot.local.LocalSnapshotStore.this"), ProblemFilters.exclude[DirectMissingMethodProblem]("akka.persistence.journal.leveldb.LeveldbStore.configPath"), ProblemFilters.exclude[DirectMissingMethodProblem]("akka.persistence.journal.leveldb.LeveldbJournal.configPath"), - ProblemFilters.exclude[DirectMissingMethodProblem]("akka.persistence.journal.leveldb.LeveldbJournal.this"), ProblemFilters.exclude[DirectMissingMethodProblem]("akka.persistence.journal.leveldb.SharedLeveldbStore.configPath"), - ProblemFilters.exclude[DirectMissingMethodProblem]("akka.persistence.journal.leveldb.SharedLeveldbStore.this"), + ProblemFilters.exclude[ReversedMissingMethodProblem]("akka.persistence.journal.leveldb.LeveldbStore.prepareConfig"), // #20737 aligned test sink and test source stage factory methods types ProblemFilters.exclude[IncompatibleResultTypeProblem]("akka.stream.testkit.TestSinkStage.apply"),