From afb5f80e0ca599b57d6ba05d86c2c48cbfa4c62b Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Fri, 20 Jul 2018 21:54:29 +0100 Subject: [PATCH] handle empty line at end of file --- .../main/groovy/com/muwire/core/files/PersisterService.groovy | 2 ++ .../com/muwire/core/files/PersisterServiceLoadingTest.groovy | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/main/groovy/com/muwire/core/files/PersisterService.groovy b/core/src/main/groovy/com/muwire/core/files/PersisterService.groovy index 0a694781..798a2c11 100644 --- a/core/src/main/groovy/com/muwire/core/files/PersisterService.groovy +++ b/core/src/main/groovy/com/muwire/core/files/PersisterService.groovy @@ -36,6 +36,8 @@ class PersisterService { def slurper = new JsonSlurper() try { location.eachLine { + if (it.trim().length() == 0) + return def parsed = slurper.parseText it def event = fromJson parsed if (event != null) diff --git a/core/src/test/groovy/com/muwire/core/files/PersisterServiceLoadingTest.groovy b/core/src/test/groovy/com/muwire/core/files/PersisterServiceLoadingTest.groovy index a379eaa9..9b6384ce 100644 --- a/core/src/test/groovy/com/muwire/core/files/PersisterServiceLoadingTest.groovy +++ b/core/src/test/groovy/com/muwire/core/files/PersisterServiceLoadingTest.groovy @@ -151,7 +151,7 @@ class PersisterServiceLoadingTest { json2 = JsonOutput.toJson(json2) persisted.append "$json1\n" - persisted.append json2 + persisted.append "$json2\n" PersisterService ps = new PersisterService(persisted, eventBus, 100, null) ps.start()