17
17
18
18
import java .util .Arrays ;
19
19
import java .util .Collection ;
20
- import java .util .Collections ;
21
- import java .util .List ;
22
20
import java .util .concurrent .CountDownLatch ;
23
21
import java .util .concurrent .atomic .AtomicReference ;
24
22
@@ -126,7 +124,7 @@ protected void terminate(Action1<Collection<SubjectObserver<? super T>>> onTermi
126
124
*/
127
125
try {
128
126
// had to circumvent type check, we know what the array contains
129
- onTerminate .call ((Collection )newState .observersList );
127
+ onTerminate .call ((Collection )Arrays . asList ( newState .observers ) );
130
128
} finally {
131
129
// mark that termination is completed
132
130
newState .terminationLatch .countDown ();
@@ -141,33 +139,29 @@ public SubjectObserver<Object>[] rawSnapshot() {
141
139
return state .get ().observers ;
142
140
}
143
141
142
+ @ SuppressWarnings ("rawtypes" )
144
143
protected static class State <T > {
145
144
final boolean terminated ;
146
145
final CountDownLatch terminationLatch ;
147
146
final Subscription [] subscriptions ;
148
- final SubjectObserver < Object > [] observers ;
147
+ final SubjectObserver [] observers ;
149
148
// to avoid lots of empty arrays
150
149
final Subscription [] EMPTY_S = new Subscription [0 ];
151
- @ SuppressWarnings ("rawtypes" )
152
150
// to avoid lots of empty arrays
153
151
final SubjectObserver [] EMPTY_O = new SubjectObserver [0 ];
154
- @ SuppressWarnings ("rawtypes" )
155
- final List <SubjectObserver <Object >> observersList ;
156
152
private State (boolean isTerminated , CountDownLatch terminationLatch ,
157
153
Subscription [] subscriptions , SubjectObserver [] observers ) {
158
154
this .terminationLatch = terminationLatch ;
159
155
this .terminated = isTerminated ;
160
156
this .subscriptions = subscriptions ;
161
157
this .observers = observers ;
162
- this .observersList = Arrays .asList (this .observers );
163
158
}
164
159
165
160
State () {
166
161
this .terminated = false ;
167
162
this .terminationLatch = null ;
168
163
this .subscriptions = EMPTY_S ;
169
164
this .observers = EMPTY_O ;
170
- observersList = Collections .emptyList ();
171
165
}
172
166
173
167
public State <T > terminate () {
0 commit comments