mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-25 09:00:26 +00:00
Property fixes
This commit is contained in:
parent
54f74c140f
commit
d41b3017f6
1 changed files with 8 additions and 11 deletions
|
@ -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())) {
|
||||
|
|
Loading…
Reference in a new issue