Skip to content

Commit

Permalink
(Minor) Use sys package instead of System when applicable (#2124)
Browse files Browse the repository at this point in the history
Use scala's `sys.exit()` instead of java's `System.exit()`, etc.
  • Loading branch information
pm47 committed Jan 6, 2022
1 parent 7421098 commit 27579a5
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 11 deletions.
5 changes: 2 additions & 3 deletions eclair-core/src/main/scala/fr/acinq/eclair/NodeParams.scala
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,10 @@ object NodeParams extends Logging {
* Order of precedence for the configuration parameters:
* 1) Java environment variables (-D...)
* 2) Configuration file eclair.conf
* 3) Optionally provided config
* 4) Default values in reference.conf
* 3) Default values in reference.conf
*/
def loadConfiguration(datadir: File): Config =
ConfigFactory.parseProperties(System.getProperties)
ConfigFactory.systemProperties()
.withFallback(ConfigFactory.parseFile(new File(datadir, "eclair.conf")))
.withFallback(ConfigFactory.load())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2352,7 +2352,7 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder, remo
|
|You should get in touch with Eclair developers and provide logs of your node for analysis.
|""".stripMargin, cause)
System.exit(1)
sys.exit(1)
stop(FSM.Shutdown)
}
}
Expand Down Expand Up @@ -2624,7 +2624,7 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder, remo
case t: SQLException =>
log.error(t, "fatal database error\n")
NotificationsLogger.logFatalError("eclair is shutting down because of a fatal database error", t)
sys.exit(-2)
sys.exit(1)
case t: Throwable => handleLocalError(t, event.stateData, None)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ object PgUtils extends JdbcUtils {
def logAndStop: LockFailureHandler = { ex =>
log(ex)
logger.error("db locking error is a fatal error")
sys.exit(-2)
sys.exit(1)
}
}

Expand Down
6 changes: 3 additions & 3 deletions eclair-front/src/main/scala/fr/acinq/eclair/Boot.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import scala.util.{Failure, Success}

object Boot extends App with Logging {
try {
val datadir = new File(System.getProperty("eclair.datadir", System.getProperty("user.home") + "/.eclair"))
val datadir = new File(sys.props.getOrElse("eclair.datadir", sys.props("user.home") + "/.eclair"))
val config = ConfigFactory.parseString(
Option(System.getenv("AKKA_CONF")).getOrElse("").replace(";", "\n"),
sys.env.getOrElse("AKKA_CONF", "").replace(";", "\n"),
ConfigParseOptions.defaults().setSyntax(ConfigSyntax.PROPERTIES))
.withFallback(ConfigFactory.parseProperties(System.getProperties))
.withFallback(ConfigFactory.parseFile(new File(datadir, "eclair.conf")))
Expand Down Expand Up @@ -58,6 +58,6 @@ object Boot extends App with Logging {
val errorMsg = if (t.getMessage != null) t.getMessage else t.getClass.getSimpleName
System.err.println(s"fatal error: $errorMsg")
logger.error(s"fatal error: $errorMsg", t)
System.exit(1)
sys.exit(1)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ClusterListener(frontJoinedCluster: Promise[Done], backendAddressFound: Pr
private def maybeShutdown(member: Member): Unit = {
if (member.roles.contains(BackendRole)) {
log.info(s"backend is down, stopping...")
System.exit(0)
sys.exit(0)
}
}

Expand Down
2 changes: 1 addition & 1 deletion eclair-node/src/main/scala/fr/acinq/eclair/Boot.scala
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,6 @@ object Boot extends App with Logging {
System.err.println(s"fatal error: $errorMsg")
logger.error(s"fatal error: $errorMsg", t)
NotificationsLogger.logFatalError("could not start eclair", t)
System.exit(1)
sys.exit(1)
}
}

0 comments on commit 27579a5

Please sign in to comment.