Skip to content

Commit

Permalink
Fix Akka issues in built runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Jul 20, 2021
1 parent 83f64aa commit 9503da7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
3 changes: 2 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -1370,7 +1370,8 @@ lazy val downloader = (project in file("lib/scala/downloader"))
"org.scalatest" %% "scalatest" % scalatestVersion % Test,
akkaActor,
akkaStream,
akkaHttp
akkaHttp,
akkaSLF4J
)
)
.dependsOn(cli)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import org.enso.cli.task.{
import java.nio.charset.{Charset, StandardCharsets}
import java.nio.file.Path
import scala.concurrent.Future
import scala.jdk.CollectionConverters.IterableHasAsJava

/** Represents a HTTP header. */
case class Header(name: String, value: String) {
Expand Down Expand Up @@ -149,12 +150,29 @@ object HTTPDownload {
}

implicit private lazy val actorSystem: ActorSystem = {
val loggers: java.lang.Iterable[String] =
Seq("akka.event.slf4j.Slf4jLogger").asJava
val config = ConfigFactory
.load()
.withValue(
"akka.extensions",
ConfigValueFactory.fromAnyRef(Seq.empty.asJava)
)
.withValue(
"akka.library-extensions",
ConfigValueFactory.fromAnyRef(Seq.empty.asJava)
)
.withValue("akka.loggers", ConfigValueFactory.fromAnyRef(loggers))
.withValue(
"akka.logging-filter",
ConfigValueFactory.fromAnyRef("akka.event.DefaultLoggingFilter")
)
.withValue("akka.loglevel", ConfigValueFactory.fromAnyRef("WARNING"))

ActorSystem(
"http-requests-actor-system",
config
config,
classLoader = getClass.getClassLoader // Note [Actor System Class Loader]
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,18 @@ class DefaultLibraryProvider(
}

case Right(version @ LibraryVersion.Published(semver, repository)) =>
publishedLibraryProvider
.findLibrary(libraryName, semver, repository)
.map(ResolvedLibrary(libraryName, version, _))
.toEither
.left
.map(ResolvingLibraryProvider.Error.DownloadFailed)
val res =
publishedLibraryProvider
.findLibrary(libraryName, semver, repository)
.map(ResolvedLibrary(libraryName, version, _))
.toEither
res match {
case Left(value) =>
println(s"Download error: $value")
value.printStackTrace()
case Right(_) =>
}
res.left.map(ResolvingLibraryProvider.Error.DownloadFailed)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class LibraryDownloadTest extends AnyWordSpec with Matchers {
val sources = pkg.listSources
sources should have size 1
sources.head.file.getName shouldEqual "Main.enso"
// TODO [RW] check that the license is missing
} finally {
server.destroy()
server.waitFor()
Expand Down

0 comments on commit 9503da7

Please sign in to comment.