@Test public void shouldThrowOnBadInclude() throws IOException { thrown.expect(FileNotFoundException.class); thrown.expectMessage(containsString("no-such-location")); xprops.load(new StringReader("#include no-such-location")); }
@Override public synchronized void load(@Nonnull final Reader reader) throws IOException { final ResourcePatternResolver loader = new PathMatchingResourcePatternResolver(); try (final CharArrayWriter writer = new CharArrayWriter()) { try (final BufferedReader lines = new BufferedReader(reader)) { for (String line = lines.readLine(); null != line; line = lines.readLine()) { writer.append(line).append('\n'); final Matcher matcher = include.matcher(line); if (matcher.matches()) for (final String x : comma .split(substitutor.replace(matcher.group(1)))) for (final Resource resource : loader .getResources(x)) { final URI uri = resource.getURI(); if (!included.add(uri)) throw new RecursiveIncludeException(uri, included); try (final InputStream in = resource .getInputStream()) { load(in); } } } } super.load(new CharArrayReader(writer.toCharArray())); } included.clear(); }
XProperties extends OrderedProperties { @Override public synchronized void load(@Nonnull final Reader reader) throws IOException { final ResourcePatternResolver loader = new PathMatchingResourcePatternResolver(); try (final CharArrayWriter writer = new CharArrayWriter()) { try (final BufferedReader lines = new BufferedReader(reader)) { for (String line = lines.readLine(); null != line; line = lines.readLine()) { writer.append(line).append('\n'); final Matcher matcher = include.matcher(line); if (matcher.matches()) for (final String x : comma .split(substitutor.replace(matcher.group(1)))) for (final Resource resource : loader .getResources(x)) { final URI uri = resource.getURI(); if (!included.add(uri)) throw new RecursiveIncludeException(uri, included); try (final InputStream in = resource .getInputStream()) { load(in); } } } } super.load(new CharArrayReader(writer.toCharArray())); } included.clear(); } }
XProperties extends OrderedProperties { @Override public synchronized void load(@Nonnull final Reader reader) throws IOException { final ResourcePatternResolver loader = new PathMatchingResourcePatternResolver(); try (final CharArrayWriter writer = new CharArrayWriter()) { try (final BufferedReader lines = new BufferedReader(reader)) { for (String line = lines.readLine(); null != line; line = lines.readLine()) { writer.append(line).append('\n'); final Matcher matcher = include.matcher(line); if (matcher.matches()) for (final String x : comma .split(substitutor.replace(matcher.group(1)))) for (final Resource resource : loader .getResources(x)) { final URI uri = resource.getURI(); if (!included.add(uri)) throw new RecursiveIncludeException(uri, included); try (final InputStream in = resource .getInputStream()) { load(in); } } } } super.load(new CharArrayReader(writer.toCharArray())); } included.clear(); } XProperties();  XProperties(@Nonnull final Map<String, String> initial); }
XProperties extends OrderedProperties { @Override public synchronized void load(@Nonnull final Reader reader) throws IOException { final ResourcePatternResolver loader = new PathMatchingResourcePatternResolver(); try (final CharArrayWriter writer = new CharArrayWriter()) { try (final BufferedReader lines = new BufferedReader(reader)) { for (String line = lines.readLine(); null != line; line = lines.readLine()) { writer.append(line).append('\n'); final Matcher matcher = include.matcher(line); if (matcher.matches()) for (final String x : comma .split(substitutor.replace(matcher.group(1)))) for (final Resource resource : loader .getResources(x)) { final URI uri = resource.getURI(); if (!included.add(uri)) throw new RecursiveIncludeException(uri, included); try (final InputStream in = resource .getInputStream()) { load(in); } } } } super.load(new CharArrayReader(writer.toCharArray())); } included.clear(); } XProperties();  XProperties(@Nonnull final Map<String, String> initial); @Nonnull static XProperties from(@Nonnull @NonNull final String absolutePath); void register(@Nonnull final String prefix,
            @Nonnull final Conversion<?, ? extends Exception> factory); @Override synchronized void load(@Nonnull final Reader reader); @Override synchronized void load(final InputStream inStream); @Nullable @Override String getProperty(final String key); @Nullable @Override synchronized Object get(final Object key); @Nullable T getObject(@Nonnull final String key); @Nullable @SuppressWarnings("unchecked") T getObjectOrDefault(@Nonnull final String key,
            @Nullable final T defaultValue); }
XProperties extends OrderedProperties { @Override public synchronized void load(@Nonnull final Reader reader) throws IOException { final ResourcePatternResolver loader = new PathMatchingResourcePatternResolver(); try (final CharArrayWriter writer = new CharArrayWriter()) { try (final BufferedReader lines = new BufferedReader(reader)) { for (String line = lines.readLine(); null != line; line = lines.readLine()) { writer.append(line).append('\n'); final Matcher matcher = include.matcher(line); if (matcher.matches()) for (final String x : comma .split(substitutor.replace(matcher.group(1)))) for (final Resource resource : loader .getResources(x)) { final URI uri = resource.getURI(); if (!included.add(uri)) throw new RecursiveIncludeException(uri, included); try (final InputStream in = resource .getInputStream()) { load(in); } } } } super.load(new CharArrayReader(writer.toCharArray())); } included.clear(); } XProperties();  XProperties(@Nonnull final Map<String, String> initial); @Nonnull static XProperties from(@Nonnull @NonNull final String absolutePath); void register(@Nonnull final String prefix,
            @Nonnull final Conversion<?, ? extends Exception> factory); @Override synchronized void load(@Nonnull final Reader reader); @Override synchronized void load(final InputStream inStream); @Nullable @Override String getProperty(final String key); @Nullable @Override synchronized Object get(final Object key); @Nullable T getObject(@Nonnull final String key); @Nullable @SuppressWarnings("unchecked") T getObjectOrDefault(@Nonnull final String key,
            @Nullable final T defaultValue);  }