Skip to content

Commit 87b2ac6

Browse files
muszynskimgalderz
muszynskim
authored andcommitted
gh-186 fix for issue
1 parent f468b96 commit 87b2ac6

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/main/scala/org/vertx/scala/platform/impl/ScalaVerticleFactory.scala

+7-8
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,11 @@ class ScalaVerticleFactory extends VerticleFactory {
5151

5252
private var loader: ClassLoader = null
5353

54-
private var interpreter: ScalaInterpreter = null
55-
5654
override def init(jvertx: JVertx, jcontainer: JContainer, aloader: ClassLoader): Unit = {
5755
this.loader = aloader
5856

5957
vertx = Vertx(jvertx)
6058
container = new Container(jcontainer)
61-
val settings = interpreterSettings()
62-
interpreter = new ScalaInterpreter(
63-
settings.get, vertx, container, new LogPrintWriter(logger))
6459
}
6560

6661
@throws(classOf[Exception])
@@ -91,11 +86,15 @@ class ScalaVerticleFactory extends VerticleFactory {
9186
}
9287

9388
def close(): Unit = {
94-
interpreter.close()
9589
}
9690

9791
private def load(main: String): Try[Verticle] = {
98-
runAsScript(main).recoverWith { case _ =>
92+
93+
val settings = interpreterSettings()
94+
val interpreter = new ScalaInterpreter(
95+
settings.get, vertx, container, new LogPrintWriter(logger))
96+
97+
runAsScript(main, interpreter).recoverWith { case _ =>
9998
// Recover by trying to compile it as a Scala class
10099
logger.info(s"Script contains compilation errors, or $main is a Scala class (pass -Dvertx.scala.interpreter.verbose=true to find out more)")
101100
logger.info(s"Compiling as a Scala class")
@@ -113,7 +112,7 @@ class ScalaVerticleFactory extends VerticleFactory {
113112
}
114113
}
115114

116-
private def runAsScript(main: String): Try[Verticle] = {
115+
private def runAsScript(main: String, interpreter:ScalaInterpreter): Try[Verticle] = {
117116
logger.info(s"Compiling $main as Scala script")
118117
// Try running it as a script
119118
for {

0 commit comments

Comments
 (0)