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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions vbus/src/main/java/de/resol/vbus/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
* The `Connection` class provides the base functionality for all VBus live
Expand All @@ -51,7 +53,7 @@ public enum ConnectionState {

protected int selfAddress;

protected ArrayList<ConnectionListener> listeners;
protected List<ConnectionListener> listeners;

protected ConnectionState connectionState;

Expand All @@ -63,7 +65,7 @@ public enum ConnectionState {
*/
protected Connection(int selfAddress) {
this.selfAddress = selfAddress;
listeners = new ArrayList<ConnectionListener>();
listeners = Collections.synchronizedList(new ArrayList<ConnectionListener>());
connectionState = ConnectionState.DISCONNECTED;
}

Expand Down