diff --git a/sentinel-extension/sentinel-datasource-apollo/pom.xml b/sentinel-extension/sentinel-datasource-apollo/pom.xml
index e01adc37..9a169fac 100644
--- a/sentinel-extension/sentinel-datasource-apollo/pom.xml
+++ b/sentinel-extension/sentinel-datasource-apollo/pom.xml
@@ -12,7 +12,7 @@
sentinel-datasource-apollo
- 1.0.0
+ 1.3.0
diff --git a/sentinel-extension/sentinel-datasource-apollo/src/main/java/com/alibaba/csp/sentinel/datasource/apollo/ApolloDataSource.java b/sentinel-extension/sentinel-datasource-apollo/src/main/java/com/alibaba/csp/sentinel/datasource/apollo/ApolloDataSource.java
index 9a7898de..45bf0a61 100644
--- a/sentinel-extension/sentinel-datasource-apollo/src/main/java/com/alibaba/csp/sentinel/datasource/apollo/ApolloDataSource.java
+++ b/sentinel-extension/sentinel-datasource-apollo/src/main/java/com/alibaba/csp/sentinel/datasource/apollo/ApolloDataSource.java
@@ -20,6 +20,7 @@ import com.google.common.collect.Sets;
* When the rule is changed in Apollo, it will take effect in real time.
*
* @author Jason Song
+ * @author Haojun Ren
*/
public class ApolloDataSource extends AbstractDataSource {
@@ -27,6 +28,8 @@ public class ApolloDataSource extends AbstractDataSource {
private final String flowRulesKey;
private final String defaultFlowRuleValue;
+ private ConfigChangeListener configChangeListener;
+
/**
* Constructs the Apollo data source
*
@@ -72,7 +75,7 @@ public class ApolloDataSource extends AbstractDataSource {
}
private void initializeConfigChangeListener() {
- config.addChangeListener(new ConfigChangeListener() {
+ configChangeListener = new ConfigChangeListener() {
@Override
public void onChange(ConfigChangeEvent changeEvent) {
ConfigChange change = changeEvent.getChange(flowRulesKey);
@@ -82,7 +85,8 @@ public class ApolloDataSource extends AbstractDataSource {
}
loadAndUpdateRules();
}
- }, Sets.newHashSet(flowRulesKey));
+ };
+ config.addChangeListener(configChangeListener, Sets.newHashSet(flowRulesKey));
}
@Override
@@ -92,6 +96,6 @@ public class ApolloDataSource extends AbstractDataSource {
@Override
public void close() throws Exception {
- // nothing to destroy
+ config.removeChangeListener(configChangeListener);
}
}