Skip to content

Commit

Permalink
Add workaround for possible SBT classpath problem.
Browse files Browse the repository at this point in the history
Under some circumstances SBT might mess up the class path which will
cause the loading of a configuration via `ConfigFactory.load()` to not
load the correct file or none at all.

To avoid this we explicitly set the class loader to use. This is
especially recommended if we're using `IO` because that might cause the
thread class loader to be used.
  • Loading branch information
jan0sch committed Dec 10, 2019
1 parent 314c73b commit 05467c2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object Pure extends IOApp {

val program = for {
(apiConfig, dbConfig) <- IO {
val cfg = ConfigFactory.load
val cfg = ConfigFactory.load(getClass().getClassLoader())
// TODO Think about alternatives to `Throw`.
(
loadConfigOrThrow[ApiConfig](cfg, "api"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ object Tapir extends IOApp {

val program = for {
(apiConfig, dbConfig) <- IO {
val cfg = ConfigFactory.load
val cfg = ConfigFactory.load(getClass().getClassLoader())
// TODO Think about alternatives to `Throw`.
(
ConfigSource.fromConfig(cfg).at("api").loadOrThrow[ApiConfig],
Expand Down

0 comments on commit 05467c2

Please sign in to comment.