Skip to content

Commit

Permalink
remove empty registry cache
Browse files Browse the repository at this point in the history
Signed-off-by: v_dylanxu <136539068@qq.com>
  • Loading branch information
dylanxu90 committed Apr 8, 2020
1 parent 12900a0 commit c3abba0
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public AbstractRegistry(URL url) {
setUrl(url);
// Start file save timer
syncSaveFile = url.getParameter(REGISTRY_FILESAVE_SYNC_KEY, false);
String filename = url.getParameter(FILE_KEY, System.getProperty(USER_HOME) + "/.fate/fate-registry-" + url.getParameter(PROJECT_KEY) + "-" + url.getAddress() + ".cache");
String filename = url.getParameter(FILE_KEY, System.getProperty(USER_HOME) + "/.fate/fate-registry-" + url.getParameter(PROJECT_KEY) + "-" + url.getHost() + "-" + url.getPort() + ".cache");
File file = null;
if (StringUtils.isNotEmpty(filename)) {
file = new File(filename);
Expand Down Expand Up @@ -441,15 +441,22 @@ private void saveProperties(URL url) {
if (buf.length() > 0) {
buf.append(URL_SEPARATOR);
}
buf.append(u.toFullString());
if (!EMPTY_PROTOCOL.equals(u.getProtocol())) {
buf.append(u.toFullString());
}
}
}
}

if (logger.isDebugEnabled()) {
logger.debug("properties set property key {} value {}", url.getServiceKey(), buf.toString());
}
properties.setProperty(url.getServiceKey(), buf.toString());

if (buf.length() == 0) {
properties.remove(url.getServiceKey());
} else {
properties.setProperty(url.getServiceKey(), buf.toString());
}
long version = lastCacheChanged.incrementAndGet();
if (syncSaveFile) {
doSaveProperties(version);
Expand Down

0 comments on commit c3abba0

Please sign in to comment.