Property fixes

This commit is contained in:
crschnick 2024-05-23 23:44:51 +00:00
parent 54f74c140f
commit d41b3017f6

View file

@ -44,11 +44,17 @@ public class AppProperties {
public AppProperties() {
var appDir = Path.of(System.getProperty("user.dir")).resolve("app");
Path propsFile = appDir.resolve("dev.properties");
if (!isJUnitTest() && Files.exists(propsFile)) {
if (Files.exists(propsFile)) {
try {
Properties props = new Properties();
props.load(Files.newInputStream(propsFile));
props.forEach((key, value) -> System.setProperty(key.toString(), value.toString()));
props.forEach((key, value) -> {
if (System.getProperty(key.toString()) != null) {
return;
}
System.setProperty(key.toString(), value.toString());
});
} catch (IOException e) {
ErrorEvent.fromThrowable(e).handle();
}
@ -99,15 +105,6 @@ public class AppProperties {
.orElse(true);
}
private static boolean isJUnitTest() {
for (StackTraceElement element : Thread.currentThread().getStackTrace()) {
if (element.getClassName().startsWith("org.junit.")) {
return true;
}
}
return false;
}
public static void logSystemProperties() {
for (var e : System.getProperties().entrySet()) {
if (List.of("user.dir").contains(e.getKey())) {