Add some more error logging for crashed workers
Change-Id: I4faf432d736a4e4d45aeb23c9aae2a5e21524e32
diff --git a/app/src/main/kotlin/de/ids_mannheim/korapxmltools/AnnotationWorkerPool.kt b/app/src/main/kotlin/de/ids_mannheim/korapxmltools/AnnotationWorkerPool.kt
index d601e4a..e5c9e68 100644
--- a/app/src/main/kotlin/de/ids_mannheim/korapxmltools/AnnotationWorkerPool.kt
+++ b/app/src/main/kotlin/de/ids_mannheim/korapxmltools/AnnotationWorkerPool.kt
@@ -68,7 +68,7 @@
outputStreamWriter.flush()
writtenBytes += text.length
} catch (e: IOException) {
- LOGGER.severe("Worker $it failed to write to process: ${e.message}")
+ LOGGER.severe("Worker $it failed to write to process in thread ${currentThread().id}: ${e.message}")
threads.remove(currentThread())
threadCount--
cancel()
@@ -110,10 +110,13 @@
// sleep(1000)
// }
//outputStreamWriter.close()
- process.waitFor()
- LOGGER.info("Worker $it finished")
-
-
+ val exitCode = process.waitFor()
+ if (exitCode != 0) {
+ LOGGER.warning("Worker $it exited with code $exitCode")
+ } else {
+ LOGGER.info("Worker $it finished")
+ }
+ threads.remove(currentThread())
} catch (e: IOException) {
e.printStackTrace()
LOGGER.warning("Worker $it failed: ${e.message}")