@Test public void continueParsingOnErrorIfRequested() throws URISyntaxException, LifecycleException { File validInput = new File(ConfigurationParserTest.class.getResource("/example.json").toURI()); File invalidInput = new File("/non/existing/file"); boolean continueOnJsonError = true; ImmutableList servers = configurationParser.parseServers(of(validInput, invalidInput), continueOnJsonError); assertThat(servers).hasSize(1); }
public ImmutableList parseServers(Iterable<File> processConfigFiles, boolean continueOnJsonError) throws LifecycleException { ServerListBuilder serverListBuilder = new ServerListBuilder(); for (File processConfigFile : processConfigFiles) { try { JmxProcess process = processConfigUtils.parseProcess(processConfigFile); log.debug("Loaded file: {}", processConfigFile.getAbsolutePath()); serverListBuilder.add(process.getServers()); } catch (Exception ex) { String message = "Error parsing json: " + processConfigFile; if (continueOnJsonError) log.error(message, ex); else throw new LifecycleException(message, ex); } } return serverListBuilder.build(); }
ConfigurationParser { public ImmutableList parseServers(Iterable<File> processConfigFiles, boolean continueOnJsonError) throws LifecycleException { ServerListBuilder serverListBuilder = new ServerListBuilder(); for (File processConfigFile : processConfigFiles) { try { JmxProcess process = processConfigUtils.parseProcess(processConfigFile); log.debug("Loaded file: {}", processConfigFile.getAbsolutePath()); serverListBuilder.add(process.getServers()); } catch (Exception ex) { String message = "Error parsing json: " + processConfigFile; if (continueOnJsonError) log.error(message, ex); else throw new LifecycleException(message, ex); } } return serverListBuilder.build(); } }
ConfigurationParser { public ImmutableList parseServers(Iterable<File> processConfigFiles, boolean continueOnJsonError) throws LifecycleException { ServerListBuilder serverListBuilder = new ServerListBuilder(); for (File processConfigFile : processConfigFiles) { try { JmxProcess process = processConfigUtils.parseProcess(processConfigFile); log.debug("Loaded file: {}", processConfigFile.getAbsolutePath()); serverListBuilder.add(process.getServers()); } catch (Exception ex) { String message = "Error parsing json: " + processConfigFile; if (continueOnJsonError) log.error(message, ex); else throw new LifecycleException(message, ex); } } return serverListBuilder.build(); } @Inject  ConfigurationParser(ProcessConfigUtils processConfigUtils); }
ConfigurationParser { public ImmutableList parseServers(Iterable<File> processConfigFiles, boolean continueOnJsonError) throws LifecycleException { ServerListBuilder serverListBuilder = new ServerListBuilder(); for (File processConfigFile : processConfigFiles) { try { JmxProcess process = processConfigUtils.parseProcess(processConfigFile); log.debug("Loaded file: {}", processConfigFile.getAbsolutePath()); serverListBuilder.add(process.getServers()); } catch (Exception ex) { String message = "Error parsing json: " + processConfigFile; if (continueOnJsonError) log.error(message, ex); else throw new LifecycleException(message, ex); } } return serverListBuilder.build(); } @Inject  ConfigurationParser(ProcessConfigUtils processConfigUtils); ImmutableList parseServers(Iterable<File> processConfigFiles, boolean continueOnJsonError); }
ConfigurationParser { public ImmutableList parseServers(Iterable<File> processConfigFiles, boolean continueOnJsonError) throws LifecycleException { ServerListBuilder serverListBuilder = new ServerListBuilder(); for (File processConfigFile : processConfigFiles) { try { JmxProcess process = processConfigUtils.parseProcess(processConfigFile); log.debug("Loaded file: {}", processConfigFile.getAbsolutePath()); serverListBuilder.add(process.getServers()); } catch (Exception ex) { String message = "Error parsing json: " + processConfigFile; if (continueOnJsonError) log.error(message, ex); else throw new LifecycleException(message, ex); } } return serverListBuilder.build(); } @Inject  ConfigurationParser(ProcessConfigUtils processConfigUtils); ImmutableList parseServers(Iterable<File> processConfigFiles, boolean continueOnJsonError);  }