From 70b66046a9bc4cdc0d112391d1dac12129efca6f Mon Sep 17 00:00:00 2001 From: xue8 <3788837@qq.com> Date: Mon, 13 Jan 2020 11:08:03 +0800 Subject: [PATCH] demo: Avoid hard-coded file separator in sentinel-demo-dynamic-file-rule module (#1247) --- .../csp/sentinel/demo/file/rule/FileDataSourceInit.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sentinel-demo/sentinel-demo-dynamic-file-rule/src/main/java/com/alibaba/csp/sentinel/demo/file/rule/FileDataSourceInit.java b/sentinel-demo/sentinel-demo-dynamic-file-rule/src/main/java/com/alibaba/csp/sentinel/demo/file/rule/FileDataSourceInit.java index 76b20a80..888c2384 100644 --- a/sentinel-demo/sentinel-demo-dynamic-file-rule/src/main/java/com/alibaba/csp/sentinel/demo/file/rule/FileDataSourceInit.java +++ b/sentinel-demo/sentinel-demo-dynamic-file-rule/src/main/java/com/alibaba/csp/sentinel/demo/file/rule/FileDataSourceInit.java @@ -15,6 +15,7 @@ */ package com.alibaba.csp.sentinel.demo.file.rule; +import java.io.File; import java.util.List; import com.alibaba.csp.sentinel.datasource.FileRefreshableDataSource; @@ -45,9 +46,9 @@ public class FileDataSourceInit implements InitFunc { @Override public void init() throws Exception { // A fake path. - String flowRuleDir = System.getProperty("user.home") + "/sentinel/rules"; + String flowRuleDir = System.getProperty("user.home") + File.separator + "sentinel" + File.separator + "rules"; String flowRuleFile = "flowRule.json"; - String flowRulePath = flowRuleDir + "/" + flowRuleFile; + String flowRulePath = flowRuleDir + File.separator + flowRuleFile; ReadableDataSource> ds = new FileRefreshableDataSource<>( flowRulePath, source -> JSON.parseObject(source, new TypeReference>() {})