Fix print logs for NamingTraceEvent.
This commit is contained in:
parent
6278e7eadb
commit
a2b997f6a7
@ -51,5 +51,15 @@ public abstract class Event implements Serializable {
|
|||||||
public String scope() {
|
public String scope() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether is plugin event. If so, the event can be dropped when no publish and subscriber without any hint. Default
|
||||||
|
* false
|
||||||
|
*
|
||||||
|
* @return {@code true} if is plugin event, otherwise {@code false}
|
||||||
|
*/
|
||||||
|
public boolean isPluginEvent() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,6 +301,9 @@ public class NotifyCenter {
|
|||||||
if (publisher != null) {
|
if (publisher != null) {
|
||||||
return publisher.publish(event);
|
return publisher.publish(event);
|
||||||
}
|
}
|
||||||
|
if (event.isPluginEvent()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
LOGGER.warn("There are no [{}] publishers for this event, please register", topic);
|
LOGGER.warn("There are no [{}] publishers for this event, please register", topic);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -31,4 +31,9 @@ public class NamingTraceEvent extends TraceEvent {
|
|||||||
String serviceNamespace, String serviceGroup, String name) {
|
String serviceNamespace, String serviceGroup, String name) {
|
||||||
super(eventType, eventTime, serviceNamespace, serviceGroup, name);
|
super(eventType, eventTime, serviceNamespace, serviceGroup, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPluginEvent() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import org.mockito.junit.MockitoJUnitRunner;
|
|||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
import static org.mockito.Mockito.atLeastOnce;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
@ -92,7 +93,7 @@ public class NamingEventPublisherTest {
|
|||||||
}
|
}
|
||||||
namingEventPublisher.addSubscriber(subscriber, TestEvent.class);
|
namingEventPublisher.addSubscriber(subscriber, TestEvent.class);
|
||||||
namingEventPublisher.publish(testEvent);
|
namingEventPublisher.publish(testEvent);
|
||||||
verify(subscriber).onEvent(testEvent);
|
verify(subscriber, atLeastOnce()).onEvent(testEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user