Skip to content

Commit a6f69c2

Browse files
committed
Remove synchronized set and add explicit synchonized to methods.
1 parent 527ae0c commit a6f69c2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

firebase-config/src/main/java/com/google/firebase/remoteconfig/internal/ConfigRealtimeHttpClient.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,19 @@
1414

1515
package com.google.firebase.remoteconfig.internal;
1616

17+
import androidx.annotation.GuardedBy;
1718
import com.google.firebase.remoteconfig.ConfigUpdateListener;
1819
import com.google.firebase.remoteconfig.ConfigUpdateListenerRegistration;
19-
import java.util.Collections;
2020
import java.util.LinkedHashSet;
2121
import java.util.Set;
2222

2323
public class ConfigRealtimeHttpClient {
2424

25+
@GuardedBy("this")
2526
private final Set<ConfigUpdateListener> listeners;
2627

2728
public ConfigRealtimeHttpClient() {
28-
listeners = Collections.synchronizedSet(new LinkedHashSet<ConfigUpdateListener>());
29+
listeners = new LinkedHashSet<ConfigUpdateListener>();
2930
}
3031

3132
// Kicks off Http stream listening and autofetch
@@ -34,14 +35,14 @@ private void beginRealtime() {}
3435
// Pauses Http stream listening
3536
private void pauseRealtime() {}
3637

37-
public ConfigUpdateListenerRegistration addRealtimeConfigUpdateListener(
38+
public synchronized ConfigUpdateListenerRegistration addRealtimeConfigUpdateListener(
3839
ConfigUpdateListener configUpdateListener) {
3940
listeners.add(configUpdateListener);
4041
beginRealtime();
4142
return new ConfigUpdateListenerRegistrationInternal(configUpdateListener);
4243
}
4344

44-
private void removeRealtimeConfigUpdateListener(ConfigUpdateListener listener) {
45+
private synchronized void removeRealtimeConfigUpdateListener(ConfigUpdateListener listener) {
4546
listeners.remove(listener);
4647
if (listeners.isEmpty()) {
4748
pauseRealtime();

0 commit comments

Comments
 (0)