Skip to content

Commit

Permalink
Review: Might be useful to see the concrete URL that /archunit.proper…
Browse files Browse the repository at this point in the history
…ties has resolved to in the logging statement

Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
  • Loading branch information
codecholeric committed Jul 21, 2019
1 parent 5c15712 commit b8d9594
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions archunit/src/main/java/com/tngtech/archunit/ArchConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -82,15 +83,18 @@ private ArchConfiguration(String propertiesResourceName) {

private void readProperties(String propertiesResourceName) {
properties.clear();
try (InputStream inputStream = getClass().getResourceAsStream(propertiesResourceName)) {
if (inputStream != null) {
LOG.info("reading ArchUnit properties from " + propertiesResourceName);
properties.load(inputStream);
} else {
LOG.debug("no ArchUnit properties file found, therefore going with default behavior");
}
} catch (IOException ignore) {
LOG.warn("problem while accessing/reading ArchUnit properties file " + propertiesResourceName,ignore);

URL archUnitPropertiesUrl = getClass().getResource(propertiesResourceName);
if (archUnitPropertiesUrl == null) {
LOG.debug("No configuration found in classpath at {} => Using default configuration", propertiesResourceName);
return;
}

try (InputStream inputStream = archUnitPropertiesUrl.openStream()) {
LOG.info("Reading ArchUnit properties from {}", archUnitPropertiesUrl);
properties.load(inputStream);
} catch (IOException e) {
LOG.warn("Error reading ArchUnit properties from " + archUnitPropertiesUrl, e);
}
}

Expand Down

0 comments on commit b8d9594

Please sign in to comment.