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

Synchronized access to Connection listeners #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

matejkraus
Copy link
Contributor

Handling connection listeners from multiple threads can cause NullPointerException.

Listeners are cloned in Connection.emitHeaderReceived, but operation listeners.toArray() is not atomic and should be synchronized.

Exception in thread "Thread-6" java.lang.NullPointerException: Cannot invoke "de.resol.vbus.ConnectionListener.datagramReceived(de.resol.vbus.Connection, de.resol.vbus.Datagram)" because "listener" is null
         at de.resol.vbus.Connection.emitHeaderReceived(Connection.java:166)

Handling connection listeners from multiple threads can cause NullPointerException.

Listeners are cloned in Connection.emitHeaderReceived, but operation listeners.toArray() is not atomic and should be synchronized.

Exception in thread "Thread-6" java.lang.NullPointerException: Cannot invoke "de.resol.vbus.ConnectionListener.datagramReceived(de.resol.vbus.Connection, de.resol.vbus.Datagram)" because "listener" is null
         at de.resol.vbus.Connection.emitHeaderReceived(Connection.java:166)
@matejkraus matejkraus closed this Dec 23, 2024
@matejkraus matejkraus reopened this Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant