14
14
15
15
package com .google .firebase .remoteconfig .internal ;
16
16
17
+ import androidx .annotation .GuardedBy ;
17
18
import com .google .firebase .remoteconfig .ConfigUpdateListener ;
18
19
import com .google .firebase .remoteconfig .ConfigUpdateListenerRegistration ;
19
- import java .util .Collections ;
20
20
import java .util .LinkedHashSet ;
21
21
import java .util .Set ;
22
22
23
23
public class ConfigRealtimeHttpClient {
24
24
25
+ @ GuardedBy ("this" )
25
26
private final Set <ConfigUpdateListener > listeners ;
26
27
27
28
public ConfigRealtimeHttpClient () {
28
- listeners = Collections . synchronizedSet ( new LinkedHashSet <ConfigUpdateListener >() );
29
+ listeners = new LinkedHashSet <ConfigUpdateListener >();
29
30
}
30
31
31
32
// Kicks off Http stream listening and autofetch
@@ -34,14 +35,14 @@ private void beginRealtime() {}
34
35
// Pauses Http stream listening
35
36
private void pauseRealtime () {}
36
37
37
- public ConfigUpdateListenerRegistration addRealtimeConfigUpdateListener (
38
+ public synchronized ConfigUpdateListenerRegistration addRealtimeConfigUpdateListener (
38
39
ConfigUpdateListener configUpdateListener ) {
39
40
listeners .add (configUpdateListener );
40
41
beginRealtime ();
41
42
return new ConfigUpdateListenerRegistrationInternal (configUpdateListener );
42
43
}
43
44
44
- private void removeRealtimeConfigUpdateListener (ConfigUpdateListener listener ) {
45
+ private synchronized void removeRealtimeConfigUpdateListener (ConfigUpdateListener listener ) {
45
46
listeners .remove (listener );
46
47
if (listeners .isEmpty ()) {
47
48
pauseRealtime ();
0 commit comments