Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NotifyCenter will throw NullPointerException when no subscriber for slowEvent #3833

Closed
KomachiSion opened this issue Sep 15, 2020 · 0 comments · Fixed by #3835
Closed

NotifyCenter will throw NullPointerException when no subscriber for slowEvent #3833

KomachiSion opened this issue Sep 15, 2020 · 0 comments · Fixed by #3835
Labels
kind/enhancement Category issues or prs related to enhancement.
Milestone

Comments

@KomachiSion
Copy link
Collaborator

Describe the bug
When nacos inner publish a SlowEvent to NotifyCenter without subscribers.

the code will throw NullPointerException because get null from subscribe map

com.alibaba.nacos.common.notify.DefaultSharePublisher line 98

Set<Subscriber> subscribers = subMappings.get(slowEventType);

Expected behavior
If no subscriber for event, it should be ignore. At most print one warn log.

Acutally behavior
throw NullPointerException

[nacos.publisher-com.alibaba.nacos.common.notify.SlowEvent] ERROR com.alibaba.nacos.common.notify.NotifyCenter - Event listener exception : {}
java.lang.NullPointerException: null
	at com.alibaba.nacos.common.notify.DefaultSharePublisher.receiveEvent(DefaultSharePublisher.java:101)
	at com.alibaba.nacos.common.notify.DefaultPublisher.openEventHandler(DefaultPublisher.java:117)
	at com.alibaba.nacos.common.notify.DefaultPublisher.run(DefaultPublisher.java:94)

How to Reproduce
Steps to reproduce the behavior:

  1. NotifyCenter.publishEvent any slowEvent without subscriber
  2. See error log

Desktop (please complete the following information):

  • OS: Any
  • Version: nacos-client 1.3.2
  • Module Any
  • SDK original

Additional context
Add any other context about the problem here.

@KomachiSion KomachiSion added the kind/enhancement Category issues or prs related to enhancement. label Sep 15, 2020
@KomachiSion KomachiSion added this to the 1.4.0 milestone Sep 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Category issues or prs related to enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant