Skip to content

Commit f6110d1

Browse files
committed
Revert "test: fix race condition in SpringAnnotationCompatibilityTest"
This reverts commit 6261c1e.
1 parent 6261c1e commit f6110d1

2 files changed

Lines changed: 2 additions & 18 deletions

File tree

apollo-compat-tests/apollo-spring-compat-it/src/test/java/com/ctrip/framework/apollo/compat/spring/SpringAnnotationCompatibilityTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import static org.junit.Assert.assertEquals;
2020
import static org.junit.Assert.assertNotNull;
21-
import static org.junit.Assert.assertTrue;
2221

2322
import com.ctrip.framework.apollo.Config;
2423
import com.ctrip.framework.apollo.ConfigService;
@@ -123,7 +122,8 @@ public void shouldSupportAnnotationAndMultipleConfig() throws Exception {
123122
assertNotNull(anotherAppChange);
124123
assertNotNull(anotherAppChange.getChange("compat.origin"));
125124

126-
assertTrue(apolloEventListenerProbe.waitForNamespace("application", 10, TimeUnit.SECONDS));
125+
String namespace = apolloEventListenerProbe.pollNamespace(10, TimeUnit.SECONDS);
126+
assertEquals("application", namespace);
127127

128128
SpringCompatibilityTestSupport.waitForCondition("public value should be updated",
129129
() -> "from-public-updated".equals(

apollo-compat-tests/apollo-spring-compat-it/src/test/java/com/ctrip/framework/apollo/compat/spring/SpringApolloEventListenerProbe.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,4 @@ public void onApplicationEvent(ApplicationEvent event) {
3737
public String pollNamespace(long timeout, TimeUnit unit) throws InterruptedException {
3838
return namespaces.poll(timeout, unit);
3939
}
40-
41-
public boolean waitForNamespace(String expectedNamespace, long timeout, TimeUnit unit)
42-
throws InterruptedException {
43-
long deadline = System.currentTimeMillis() + unit.toMillis(timeout);
44-
while (System.currentTimeMillis() < deadline) {
45-
long remaining = deadline - System.currentTimeMillis();
46-
if (remaining <= 0) {
47-
break;
48-
}
49-
String namespace = namespaces.poll(remaining, TimeUnit.MILLISECONDS);
50-
if (expectedNamespace.equals(namespace)) {
51-
return true;
52-
}
53-
}
54-
return false;
55-
}
5640
}

0 commit comments

Comments
 (0)