@Test public void testCircularIncludes() throws IOException { File a = temp.newFile("a.cfg"); File b = temp.newFile("b.cfg"); File c = temp.newFile("c.cfg"); writeContentTo("include \"b.cfg\" as a\n" + "config.Database {}\n", a); writeContentTo("include \"c.cfg\" as a\n" + "config.Database {}\n", b); writeContentTo("include \"a.cfg\" as a\n" + "config.Database {}\n", c); ProvidenceConfigParser config = new ProvidenceConfigParser(registry, false); try { config.parseConfig(a.toPath(), null); fail("no exception on circular deps"); } catch (SerializerException e) { assertEquals("Circular includes detected: a.cfg -> b.cfg -> c.cfg -> a.cfg", e.getMessage()); } }
@Nonnull <M extends PMessage<M, F>, F extends PField> Pair<M, Set<String>> parseConfig(@Nonnull Path configFile, @Nullable M parent) throws ProvidenceConfigException { try { configFile = canonicalFileLocation(configFile); } catch (IOException e) { throw new ProvidenceConfigException(e, "Unable to resolve config file " + configFile) .setFile(configFile.getFileName() .toString()); } Pair<M, Set<String>> result = checkAndParseInternal(configFile, parent); if (result == null) { throw new ProvidenceConfigException("No config: " + configFile.toString()) .setFile(configFile.getFileName() .toString()); } return result; }
ProvidenceConfigParser { @Nonnull <M extends PMessage<M, F>, F extends PField> Pair<M, Set<String>> parseConfig(@Nonnull Path configFile, @Nullable M parent) throws ProvidenceConfigException { try { configFile = canonicalFileLocation(configFile); } catch (IOException e) { throw new ProvidenceConfigException(e, "Unable to resolve config file " + configFile) .setFile(configFile.getFileName() .toString()); } Pair<M, Set<String>> result = checkAndParseInternal(configFile, parent); if (result == null) { throw new ProvidenceConfigException("No config: " + configFile.toString()) .setFile(configFile.getFileName() .toString()); } return result; } }
ProvidenceConfigParser { @Nonnull <M extends PMessage<M, F>, F extends PField> Pair<M, Set<String>> parseConfig(@Nonnull Path configFile, @Nullable M parent) throws ProvidenceConfigException { try { configFile = canonicalFileLocation(configFile); } catch (IOException e) { throw new ProvidenceConfigException(e, "Unable to resolve config file " + configFile) .setFile(configFile.getFileName() .toString()); } Pair<M, Set<String>> result = checkAndParseInternal(configFile, parent); if (result == null) { throw new ProvidenceConfigException("No config: " + configFile.toString()) .setFile(configFile.getFileName() .toString()); } return result; } ProvidenceConfigParser(TypeRegistry registry, boolean strict); }
ProvidenceConfigParser { @Nonnull <M extends PMessage<M, F>, F extends PField> Pair<M, Set<String>> parseConfig(@Nonnull Path configFile, @Nullable M parent) throws ProvidenceConfigException { try { configFile = canonicalFileLocation(configFile); } catch (IOException e) { throw new ProvidenceConfigException(e, "Unable to resolve config file " + configFile) .setFile(configFile.getFileName() .toString()); } Pair<M, Set<String>> result = checkAndParseInternal(configFile, parent); if (result == null) { throw new ProvidenceConfigException("No config: " + configFile.toString()) .setFile(configFile.getFileName() .toString()); } return result; } ProvidenceConfigParser(TypeRegistry registry, boolean strict);  }
ProvidenceConfigParser { @Nonnull <M extends PMessage<M, F>, F extends PField> Pair<M, Set<String>> parseConfig(@Nonnull Path configFile, @Nullable M parent) throws ProvidenceConfigException { try { configFile = canonicalFileLocation(configFile); } catch (IOException e) { throw new ProvidenceConfigException(e, "Unable to resolve config file " + configFile) .setFile(configFile.getFileName() .toString()); } Pair<M, Set<String>> result = checkAndParseInternal(configFile, parent); if (result == null) { throw new ProvidenceConfigException("No config: " + configFile.toString()) .setFile(configFile.getFileName() .toString()); } return result; } ProvidenceConfigParser(TypeRegistry registry, boolean strict);   }