You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eventmesh.apache.org by mi...@apache.org on 2022/10/31 03:21:27 UTC
[incubator-eventmesh] branch master updated: optimize ConfigurationWrapper construct
This is an automated email from the ASF dual-hosted git repository.
mikexue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-eventmesh.git
The following commit(s) were added to refs/heads/master by this push:
new ffef68e1 optimize ConfigurationWrapper construct
new c8618029 Merge pull request #2021 from mikechengwei/optimizeRuntimeInit
ffef68e1 is described below
commit ffef68e195f9f748d1788a3ff8290133647a1273
Author: mikechengwei <84...@qq.com>
AuthorDate: Sun Oct 30 01:48:27 2022 +0800
optimize ConfigurationWrapper construct
---
.../org/apache/eventmesh/common/config/ConfigurationWrapper.java | 3 +++
.../apache/eventmesh/common/config/ConfigurationWrapperTest.java | 6 ++++++
.../org/apache/eventmesh/runtime/constants/EventMeshConstants.java | 4 +++-
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/eventmesh-common/src/main/java/org/apache/eventmesh/common/config/ConfigurationWrapper.java b/eventmesh-common/src/main/java/org/apache/eventmesh/common/config/ConfigurationWrapper.java
index c3e88e34..10d470d6 100644
--- a/eventmesh-common/src/main/java/org/apache/eventmesh/common/config/ConfigurationWrapper.java
+++ b/eventmesh-common/src/main/java/org/apache/eventmesh/common/config/ConfigurationWrapper.java
@@ -30,9 +30,11 @@ import java.io.IOException;
import java.util.Map.Entry;
import java.util.Properties;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.apache.logging.log4j.util.Strings;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Preconditions;
@@ -63,6 +65,7 @@ public class ConfigurationWrapper {
};
public ConfigurationWrapper(String directoryPath, String fileName, boolean reload) {
+ Preconditions.checkArgument(Strings.isNotEmpty(directoryPath),"please configure environment variable 'confPath'");
this.directoryPath = directoryPath
.replace('/', File.separator.charAt(0))
.replace('\\', File.separator.charAt(0));
diff --git a/eventmesh-common/src/test/java/org/apache/eventmesh/common/config/ConfigurationWrapperTest.java b/eventmesh-common/src/test/java/org/apache/eventmesh/common/config/ConfigurationWrapperTest.java
index 73503dc1..78b84c6d 100644
--- a/eventmesh-common/src/test/java/org/apache/eventmesh/common/config/ConfigurationWrapperTest.java
+++ b/eventmesh-common/src/test/java/org/apache/eventmesh/common/config/ConfigurationWrapperTest.java
@@ -39,4 +39,10 @@ public class ConfigurationWrapperTest {
Assert.assertEquals("value1", wraper.getProp("eventMesh.server.env"));
Assert.assertEquals("value2", wraper.getProp("eventMesh.server.idc"));
}
+
+ @Test(expected = IllegalArgumentException.class)
+ public void construct(){
+ ConfigurationWrapper newWrapper = new ConfigurationWrapper(null, "eventmesh.properties", false);
+ }
+
}
diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/constants/EventMeshConstants.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/constants/EventMeshConstants.java
index 1b33303b..9e45f69b 100644
--- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/constants/EventMeshConstants.java
+++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/constants/EventMeshConstants.java
@@ -34,8 +34,10 @@ public class EventMeshConstants {
public static final String DEFAULT_CHARSET = "UTF-8";
public static final String IP_PORT_SEPARATOR = ":";
+
+ public static final String CONF_ENV="confPath";
- public static final String EVENTMESH_CONF_HOME = System.getProperty("confPath", System.getenv("confPath"));
+ public static final String EVENTMESH_CONF_HOME = System.getProperty(CONF_ENV, System.getenv(CONF_ENV));
public static final String EVENTMESH_CONF_FILE = "eventmesh.properties";
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: commits-help@eventmesh.apache.org