demo: Avoid hard-coded file separator in sentinel-demo-dynamic-file-rule module (#1247)
This commit is contained in:
parent
9cc52706f5
commit
70b66046a9
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package com.alibaba.csp.sentinel.demo.file.rule;
|
package com.alibaba.csp.sentinel.demo.file.rule;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.alibaba.csp.sentinel.datasource.FileRefreshableDataSource;
|
import com.alibaba.csp.sentinel.datasource.FileRefreshableDataSource;
|
||||||
|
|
@ -45,9 +46,9 @@ public class FileDataSourceInit implements InitFunc {
|
||||||
@Override
|
@Override
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
// A fake path.
|
// 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 flowRuleFile = "flowRule.json";
|
||||||
String flowRulePath = flowRuleDir + "/" + flowRuleFile;
|
String flowRulePath = flowRuleDir + File.separator + flowRuleFile;
|
||||||
|
|
||||||
ReadableDataSource<String, List<FlowRule>> ds = new FileRefreshableDataSource<>(
|
ReadableDataSource<String, List<FlowRule>> ds = new FileRefreshableDataSource<>(
|
||||||
flowRulePath, source -> JSON.parseObject(source, new TypeReference<List<FlowRule>>() {})
|
flowRulePath, source -> JSON.parseObject(source, new TypeReference<List<FlowRule>>() {})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue