Skip to content

Commit

Permalink
fix the unit test NullPointerException
Browse files Browse the repository at this point in the history
  • Loading branch information
vdiskg committed Jul 3, 2021
1 parent d4a12e2 commit 39d6482
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.Queue;
import java.util.UUID;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Test;
Expand Down Expand Up @@ -383,7 +384,8 @@ public void testApolloConfigChangeListenerWithInterestedKeyPrefixes() {
}

@Test
public void testApolloConfigChangeListenerWithInterestedKeyPrefixes_fire() {
public void testApolloConfigChangeListenerWithInterestedKeyPrefixes_fire()
throws InterruptedException {
// default mock, useless here
// just for speed up test without waiting
mockConfig(ConfigConsts.NAMESPACE_APPLICATION, mock(Config.class));
Expand Down Expand Up @@ -946,16 +948,16 @@ private static class TestApolloConfigChangeListenerWithInterestedKeyPrefixesBean

static final String SPECIAL_NAMESPACE = "special-namespace-2021";

private final Queue<ConfigChangeEvent> configChangeEventQueue = new ArrayBlockingQueue<>(100);
private final BlockingQueue<ConfigChangeEvent> configChangeEventQueue = new ArrayBlockingQueue<>(100);

@ApolloConfigChangeListener(value = SPECIAL_NAMESPACE, interestedKeyPrefixes = {"number",
"logging.level"})
private void onChange(ConfigChangeEvent changeEvent) {
this.configChangeEventQueue.add(changeEvent);
}

public ConfigChangeEvent getConfigChangeEvent() {
return this.configChangeEventQueue.poll();
public ConfigChangeEvent getConfigChangeEvent() throws InterruptedException {
return this.configChangeEventQueue.take();
}
}

Expand Down

0 comments on commit 39d6482

Please sign in to comment.