Skip to content

Commit

Permalink
#6529: add synchronizedList
Browse files Browse the repository at this point in the history
  • Loading branch information
jaroslawmalekcodete committed Dec 19, 2017
1 parent e05c670 commit 922c6e5
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
import java.util.ArrayList;
import java.util.List;

import static java.util.Collections.synchronizedList;
import static java.util.Collections.unmodifiableList;

public class KernelSocketsTest extends KernelSockets {

private volatile List<Message> publishedMessages = new ArrayList<>();
private volatile List<Message> sentMessages = new ArrayList<>();
private volatile List<Message> publishedMessages = synchronizedList(new ArrayList<>());
private volatile List<Message> sentMessages = synchronizedList(new ArrayList<>());

@Override
public void publish(Message message) {
Expand All @@ -47,7 +48,7 @@ public List<Message> getSentMessages() {
}

public void clear() {
publishedMessages = new ArrayList<>();
sentMessages = new ArrayList<>();
publishedMessages = synchronizedList(new ArrayList<>());
sentMessages = synchronizedList(new ArrayList<>());
}
}

0 comments on commit 922c6e5

Please sign in to comment.