diff --git a/CHANGELOG.md b/CHANGELOG.md index aa841c7b979..a6186489778 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.6.1(Dec, 2018) + +[#421] NamingService's serivce name can't use colon(:) in Windows +[#432] When packing nacos-core, ${user.home} is replaced in the logback configuration file (nacos.xml) + ## 0.6.0(Dec, 2018) * [#388] Cluster name should be provided in the Instance diff --git a/README.md b/README.md index a91e959a953..8b4c18b1593 100644 --- a/README.md +++ b/README.md @@ -40,9 +40,9 @@ It is super easy to get started with your first project. You can download the package from the [latest stable release](https://github.com/alibaba/nacos/releases). -Take release nacos-server-0.6.0.zip for example. +Take release nacos-server-0.6.1.zip for example. ``` -unzip nacos-server-0.6.0.zip +unzip nacos-server-0.6.1.zip cd nacos/bin ``` diff --git a/api/src/main/java/com/alibaba/nacos/api/naming/pojo/ServiceInfo.java b/api/src/main/java/com/alibaba/nacos/api/naming/pojo/ServiceInfo.java index 0bdb4a14bba..b5dba2501da 100644 --- a/api/src/main/java/com/alibaba/nacos/api/naming/pojo/ServiceInfo.java +++ b/api/src/main/java/com/alibaba/nacos/api/naming/pojo/ServiceInfo.java @@ -17,6 +17,8 @@ import com.alibaba.fastjson.annotation.JSONField; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -191,6 +193,15 @@ public String getKey() { return getKey(name, clusters, env, isAllIPs()); } + @JSONField(serialize = false) + public String getKeyEncoded() { + try { + return getKey(URLEncoder.encode(name, "UTF-8"), clusters, env, isAllIPs()); + } catch (UnsupportedEncodingException e) { + return getKey(); + } + } + @JSONField(serialize = false) public static String getKey(String name, String clusters, String unit) { return getKey(name, clusters, unit, false); diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/cache/DiskCache.java b/client/src/main/java/com/alibaba/nacos/client/naming/cache/DiskCache.java index 2de1b283490..396eb86f604 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/cache/DiskCache.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/cache/DiskCache.java @@ -25,6 +25,7 @@ import java.io.BufferedReader; import java.io.File; import java.io.StringReader; +import java.net.URLDecoder; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.HashMap; @@ -41,7 +42,9 @@ public static void write(ServiceInfo dom, String dir) { try { makeSureCacheDirExists(dir); - File file = new File(dir, dom.getKey()); + + + File file = new File(dir, dom.getKeyEncoded()); if (!file.exists()) { // add another !file.exists() to avoid conflicted creating-new-file from multi-instances if (!file.createNewFile() && !file.exists()) { @@ -87,9 +90,11 @@ public static Map read(String cacheDir) { continue; } - if (!(file.getName().endsWith(ServiceInfo.SPLITER + "meta") || file.getName().endsWith( + String fileName = URLDecoder.decode(file.getName(), "UTF-8"); + + if (!(fileName.endsWith(ServiceInfo.SPLITER + "meta") || fileName.endsWith( ServiceInfo.SPLITER + "special-url"))) { - ServiceInfo dom = new ServiceInfo(file.getName()); + ServiceInfo dom = new ServiceInfo(fileName); List ips = new ArrayList(); dom.setHosts(ips); diff --git a/core/pom.xml b/core/pom.xml index 50ae32073f1..74ba8f2b461 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -64,13 +64,4 @@ - - - - - src/main/resources - true - - - diff --git a/core/src/main/resources/banner.txt b/core/src/main/resources/banner.txt index 7f33937ec3f..22d52a96fcf 100644 --- a/core/src/main/resources/banner.txt +++ b/core/src/main/resources/banner.txt @@ -1,7 +1,7 @@ ,--. ,--.'| - ,--,: : | Nacos ${nacos.version} + ,--,: : | Nacos 0.6.1 ,`--.'`| ' : ,---. Running in ${nacos.mode} mode | : : | | ' ,'\ .--.--. Port: 8848 : | \ | : ,--.--. ,---. / / | / / ' Pid: ${pid} diff --git a/naming/src/main/java/com/alibaba/nacos/naming/raft/RaftStore.java b/naming/src/main/java/com/alibaba/nacos/naming/raft/RaftStore.java index 0a4b3e716f0..d4e518403e3 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/raft/RaftStore.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/raft/RaftStore.java @@ -107,7 +107,7 @@ public synchronized static void load(String key) throws Exception{ Loggers.RAFT.warn("warning: encountered directory in cache dir: " + cache.getAbsolutePath()); } - if (!StringUtils.equals(cache.getName(), key)) { + if (!StringUtils.equals(decodeFileName(cache.getName()), key)) { continue; } @@ -139,7 +139,7 @@ public synchronized static void load(String key) throws Exception{ } public synchronized static void write(final Datum datum) throws Exception { - File cacheFile = new File(CACHE_DIR + File.separator + datum.key); + File cacheFile = new File(CACHE_DIR + File.separator + encodeFileName(datum.key)); if (!cacheFile.exists() && !cacheFile.getParentFile().mkdirs() && !cacheFile.createNewFile()) { throw new IllegalStateException("can not make cache file: " + cacheFile.getName()); } @@ -169,7 +169,7 @@ private static File[] listCaches() throws Exception { } public static void delete(Datum datum) { - File cacheFile = new File(CACHE_DIR + File.separator + datum.key); + File cacheFile = new File(CACHE_DIR + File.separator + encodeFileName(datum.key)); if (!cacheFile.delete()) { Loggers.RAFT.error("RAFT-DELETE", "failed to delete datum: " + datum.key + ", value: " + datum.value); throw new IllegalStateException("failed to delete datum: " + datum.key); @@ -188,4 +188,12 @@ public static void updateTerm(long term) throws Exception { meta.store(outStream, null); } } + + private static String encodeFileName(String fileName) { + return fileName.replace(':', '#'); + } + + private static String decodeFileName(String fileName) { + return fileName.replace("#", ":"); + } }