Skip to content

Commit

Permalink
safe read
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Dec 24, 2024
1 parent ea889ec commit b143d39
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/rultor/Env.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private Env() {
public static String read(final String name) {
final String xml = System.getenv(Env.SETTINGS_XML);
final String ret;
if (xml == null) {
if (xml == null || Manifests.exists(name) && !Manifests.read(name).startsWith("${")) {
ret = Manifests.read(name);
} else {
final String res = "rultor-mf/MANIFEST.MF";
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ Rultor-TwitterTokenSecret: ${twitter.tsecret}
Rultor-SentryDsn: ${sentry.dsn}
Rultor-GpgPublic: ${gpg.public}
Rultor-GpgSecret: ${gpg.secret}
Rultor-Test: ${test}
4 changes: 2 additions & 2 deletions src/test/java/com/rultor/EnvTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void readsFromSettingsXml() {
String.join(
"",
"<settings><profiles><profile><properties>",
"<dynamo.key>hello</dynamo.key>",
"<test>hello</test>",
"</properties></profile></profiles></settings>"
)
);
Expand All @@ -91,7 +91,7 @@ void readsFromSettingsXml() {
);
MatcherAssert.assertThat(
"takes the right value",
Env.read("Rultor-DynamoKey"),
Env.read("Rultor-Test"),
Matchers.equalTo("hello")
);
}
Expand Down
11 changes: 6 additions & 5 deletions src/test/resources/log4j.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=com.jcabi.log.MulticolorLayout
log4j.appender.CONSOLE.layout.ConversionPattern=[%color{%p}] %c{1}: %m%n

log4j.logger.com.rultor=INFO
log4j.logger.com.jcabi.dynamo=INFO
log4j.logger.com.jcabi.github=INFO
log4j.logger.com.rultor=WARN
log4j.logger.com.jcabi.dynamo=WARN
log4j.logger.com.jcabi.github=WARN
log4j.logger.com.jcabi.xml.StrictXML=ERROR
log4j.logger.com.jcabi.http.wire.VerboseWire=WARN
log4j.logger.com.jcabi.manifests=INFO
log4j.logger.co.stateful.mock=DEBUG
log4j.logger.com.jcabi.manifests=WARN
log4j.logger.co.stateful.mock=WARN

0 comments on commit b143d39

Please sign in to comment.