From 91166f48b9bfadaa1533c2ac7ad988e21c0f5354 Mon Sep 17 00:00:00 2001 From: kurzum Date: Mon, 23 Mar 2020 11:46:52 +0100 Subject: [PATCH] fix for opened file lock after delete --- .../databus/derive/mojo/CloneGoal.scala | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/scala/org/dbpedia/databus/derive/mojo/CloneGoal.scala b/src/main/scala/org/dbpedia/databus/derive/mojo/CloneGoal.scala index 2c69a6b..d12b052 100644 --- a/src/main/scala/org/dbpedia/databus/derive/mojo/CloneGoal.scala +++ b/src/main/scala/org/dbpedia/databus/derive/mojo/CloneGoal.scala @@ -17,6 +17,7 @@ import scala.collection.JavaConverters._ import scala.collection.parallel.ForkJoinTaskSupport import scala.concurrent.forkjoin.ForkJoinPool import scala.language.postfixOps +import scala.sys.process import scala.sys.process.Process /** @author Marvin Hofer @@ -249,16 +250,22 @@ class CloneGoal extends AbstractMojo { if (rFilter.pattern.matcher(downFile.name).matches) { System.err.println(s"[INFO] Parsing ${downFile.name}") + val finalFileOutputStream : java.io.OutputStream = finalFile.newOutputStream + val reportFileOutputStream : java.io.OutputStream = reportFile.newOutputStream + parseFile( downFile, - finalFile.newOutputStream, - reportFile.newOutputStream, + finalFileOutputStream, + reportFileOutputStream, parChunks, chunkSize, ReportFormat.TEXT, removeWarnings = true ) + finalFileOutputStream.close() + reportFileOutputStream.close() + lbzip2File(finalFile) lbzip2File(reportFile) @@ -283,7 +290,7 @@ class CloneGoal extends AbstractMojo { val sortMemory = "20%" val sortParallel = "8" - val cmd = Seq( + val cmd: Seq[String] = Seq( "bash", "-c", s"LC_ALL=C sort -S $sortMemory -u --parallel=$sortParallel ${file.pathAsString} " + @@ -293,7 +300,11 @@ class CloneGoal extends AbstractMojo { System.err.println(s"[INFO] ${cmd.mkString(" ")}") - Process(cmd).! + val process = Process(cmd).run() + val exitValue = process.exitValue() + process.destroy() + + } val pluginVersion = "1.3-SNAPSHOT"