[
https://issues.apache.org/jira/browse/SCB-658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16507561#comment-16507561
]
ASF GitHub Bot commented on SCB-658:
------------------------------------
wujimin commented on a change in pull request #761: [SCB-658]
MicroserviceVersions eventbus leak
URL:
https://github.com/apache/incubator-servicecomb-java-chassis/pull/761#discussion_r194276928
##########
File path:
service-registry/src/test/java/org/apache/servicecomb/serviceregistry/consumer/TestMicroserviceManager.java
##########
@@ -98,11 +100,23 @@ public void testCreateRuleServiceNotExists() {
}
};
+ AtomicInteger triggerCount = new AtomicInteger();
+ new MockUp<MicroserviceVersions>() {
+ @Mock
+ void onMicroserviceInstanceChanged(MicroserviceInstanceChangedEvent
changedEvent) {
+ triggerCount.incrementAndGet();
+ }
+ };
+
MicroserviceVersionRule microserviceVersionRule =
microserviceManager.getOrCreateMicroserviceVersionRule(serviceName,
versionRule);
Assert.assertEquals("0.0.0+",
microserviceVersionRule.getVersionRule().getVersionRule());
Assert.assertNull(microserviceVersionRule.getLatestMicroserviceVersion());
Assert.assertEquals(0, cachedVersions.size());
+
+ MicroserviceInstanceChangedEvent changedEvent = new
MicroserviceInstanceChangedEvent();
+ eventBus.post(changedEvent);
+ Assert.assertEquals(0, triggerCount.get());
Review comment:
it can verify the unregister really
if delete the unregister code, then this case will failed.
when invoke microserviceManager.getOrCreateMicroserviceVersionRule
if related MicroserviceVersions is not exist, will create a new instance,
the instance will register to eventBus
if some error happened, the created MicroserviceVersions will be removed
from microserviceManager automaticlly
if not unregister from eventBus, then triggerCount will be 1 not 0
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> leak of MicroserviceVersions register to EventBus
> -------------------------------------------------
>
> Key: SCB-658
> URL: https://issues.apache.org/jira/browse/SCB-658
> Project: Apache ServiceComb
> Issue Type: Bug
> Components: Java-Chassis
> Reporter: wujimin
> Assignee: wujimin
> Priority: Major
>
> org.apache.servicecomb.serviceregistry.consumer.MicroserviceManager#getOrCreateMicroserviceVersions
> when removed from versionsByName, microserviceVersions must unregistered from
> eventBus
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)