You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/06/11 01:13:02 UTC
[GitHub] wujimin commented on a change in pull request #761: [SCB-658]
MicroserviceVersions eventbus leak
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 happend, 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:
users@infra.apache.org
With regards,
Apache Git Services