diff --git a/.gitignore b/.gitignore index 87a538f5ef..22b50914a2 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* +*.DS_Store /.idea/ .idea/ *.iml @@ -168,7 +169,6 @@ Migrations/ /target/ /wfc/target/ -*.DS_Store /e2e-tests/emb-json/target/ /process_data/ /e2e-tests/spring-rest-multidb/target/ diff --git a/core/src/main/kotlin/org/evomaster/core/solver/SMTLibZ3DbConstraintSolver.kt b/core/src/main/kotlin/org/evomaster/core/solver/SMTLibZ3DbConstraintSolver.kt index be3002deb8..8e0e5655e4 100644 --- a/core/src/main/kotlin/org/evomaster/core/solver/SMTLibZ3DbConstraintSolver.kt +++ b/core/src/main/kotlin/org/evomaster/core/solver/SMTLibZ3DbConstraintSolver.kt @@ -33,6 +33,7 @@ import java.nio.file.Files import java.nio.file.Paths import java.util.* import javax.annotation.PostConstruct +import javax.annotation.PreDestroy /** * An SMT solver implementation using Z3 in a Docker container. @@ -42,15 +43,12 @@ import javax.annotation.PostConstruct */ class SMTLibZ3DbConstraintSolver() : DbConstraintSolver { private val resourcesFolder = System.getProperty("user.dir") + "/target/tmp" - private lateinit var executor: Z3DockerExecutor + private lateinit var executor: Z3DockerExecutor private var idCounter: Long = 0L @Inject private lateinit var config: EMConfig - @Inject - private lateinit var time: SearchTimeController - @PostConstruct private fun postConstruct() { if (config.generateSqlDataWithDSE) { @@ -65,6 +63,7 @@ class SMTLibZ3DbConstraintSolver() : DbConstraintSolver { /** * Closes the Z3 Docker executor and cleans up temporary files. */ + @PreDestroy override fun close() { executor.close() try { diff --git a/solver/src/main/java/org/evomaster/solver/Z3DockerExecutor.java b/solver/src/main/java/org/evomaster/solver/Z3DockerExecutor.java index 15dc50ecc8..ba91eb421f 100644 --- a/solver/src/main/java/org/evomaster/solver/Z3DockerExecutor.java +++ b/solver/src/main/java/org/evomaster/solver/Z3DockerExecutor.java @@ -84,6 +84,8 @@ public Optional> solveFromFile(String fileName) { */ @Override public void close() { - z3Prover.stop(); + if (z3Prover != null) { + z3Prover.stop(); + } } }