Platform: Include invalid property names in exception message
In some runtime environments (i.e. during CI tests), the logger might
not be available when the config.properties file is validated. The names
of the invalid properties would then be unknown which makes the error
hard to fix. Including the invalid property names in the exception
message can help in this case.
[CP from 6.1.x]
Change-Id: I0e1c3b14264f3aa7e73ff8e98c13e2fcce076ab5
diff --git a/org.eclipse.scout.rt.platform/src/main/java/org/eclipse/scout/rt/platform/internal/PlatformImplementor.java b/org.eclipse.scout.rt.platform/src/main/java/org/eclipse/scout/rt/platform/internal/PlatformImplementor.java
index 79df263..66916b5 100644
--- a/org.eclipse.scout.rt.platform/src/main/java/org/eclipse/scout/rt/platform/internal/PlatformImplementor.java
+++ b/org.eclipse.scout.rt.platform/src/main/java/org/eclipse/scout/rt/platform/internal/PlatformImplementor.java
@@ -11,6 +11,7 @@
package org.eclipse.scout.rt.platform.internal;
import java.awt.GraphicsEnvironment;
+import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
@@ -187,18 +188,18 @@
LOG.info("No {} found. Running with empty configuration.", ConfigUtility.CONFIG_FILE_NAME);
}
- int errorCount = 0;
+ final List<String> invalidProperties = new ArrayList<>();
for (IConfigProperty prop : BEANS.all(IConfigProperty.class)) {
try {
prop.getValue();
}
catch (Exception ex) {
- errorCount++;
+ invalidProperties.add(prop.getKey());
LOG.error("Failed reading config property '{}'", prop.getKey(), ex);
}
}
- if (errorCount > 0) {
- throw new PlatformException("Cannot start platform due to " + errorCount + " invalid config properties");
+ if (!invalidProperties.isEmpty()) {
+ throw new PlatformException("Cannot start platform due to {} invalid config properties: {}", invalidProperties.size(), invalidProperties);
}
}