From c249317694e4f218517ff177dbe247eafbddd7ef Mon Sep 17 00:00:00 2001 From: Ulisses Lima Date: Mon, 14 Mar 2022 23:34:39 -0300 Subject: [PATCH] warn instead of throw --- .../baeldung/SpringBootPersistenceApplication.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/SpringBootPersistenceApplication.java b/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/SpringBootPersistenceApplication.java index a5cb443291..bbda5823f8 100644 --- a/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/SpringBootPersistenceApplication.java +++ b/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/SpringBootPersistenceApplication.java @@ -47,12 +47,13 @@ public class SpringBootPersistenceApplication implements ApplicationRunner { jsonLines = ImportUtils.lines(new File(source)); } - if (jsonLines == null || jsonLines.isEmpty()) - throw new IllegalArgumentException("no input to import"); - - ImportJsonService importService = context.getBean(ImportJsonService.class); - String result = importService.importTo(collection, jsonLines); - log.info(source + " - result: " + result); + if (jsonLines == null || jsonLines.isEmpty()) { + log.warn(source + " - no input to import"); + } else { + ImportJsonService importService = context.getBean(ImportJsonService.class); + String result = importService.importTo(collection, jsonLines); + log.info(source + " - import result: " + result); + } } } }