From a579d6b2bbe20060ee674bb2b642c3e995a3c5ec Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Fri, 25 Mar 2011 11:32:09 +0100 Subject: [PATCH] Closing ticket #721, shutting down the VM if theres a broken config supplied --- .../src/main/scala/akka/config/Config.scala | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/akka-actor/src/main/scala/akka/config/Config.scala b/akka-actor/src/main/scala/akka/config/Config.scala index 2d25e8383e..7d50e59cd7 100644 --- a/akka-actor/src/main/scala/akka/config/Config.scala +++ b/akka-actor/src/main/scala/akka/config/Config.scala @@ -5,10 +5,6 @@ package akka.config import akka.AkkaException -import akka.event.EventHandler - -import java.net.InetSocketAddress -import java.lang.reflect.Method class ConfigurationException(message: String) extends AkkaException(message) class ModuleNotAvailableException(message: String) extends AkkaException(message) @@ -35,10 +31,8 @@ object Config { envHome orElse systemHome } - val config = { - + val config: Configuration = try { val confName = { - val envConf = System.getenv("AKKA_MODE") match { case null | "" => None case value => Some(value) @@ -52,7 +46,7 @@ object Config { (envConf orElse systemConf).map("akka." + _ + ".conf").getOrElse("akka.conf") } - try { + val newInstance = if (System.getProperty("akka.config", "") != "") { val configFile = System.getProperty("akka.config", "") println("Loading config from -Dakka.config=" + configFile) @@ -75,18 +69,23 @@ object Config { "\nUsing default values everywhere.") Configuration.fromString("akka {}") // default empty config } - } catch { - case e => - EventHandler.error(e, this, e.getMessage) - throw e - } + + val configVersion = newInstance.getString("akka.version", VERSION) + if (configVersion != VERSION) + throw new ConfigurationException( + "Akka JAR version [" + VERSION + "] is different than the provided config version [" + configVersion + "]") + + newInstance + } catch { + case e => + System.err.println("Couldn't parse config, fatal error.") + e.printStackTrace(System.err) + System.exit(-1) + throw e } val CONFIG_VERSION = config.getString("akka.version", VERSION) - if (VERSION != CONFIG_VERSION) throw new ConfigurationException( - "Akka JAR version [" + VERSION + "] is different than the provided config version [" + CONFIG_VERSION + "]") - val TIME_UNIT = config.getString("akka.time-unit", "seconds") val startTime = System.currentTimeMillis