1
1
/*
2
- * Copyright (c) 2015-2021 VMware Inc. or its affiliates, All Rights Reserved.
2
+ * Copyright (c) 2015-2024 VMware Inc. or its affiliates, All Rights Reserved.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -55,13 +55,12 @@ public void rejectedExecutionExceptionOnDataSignalExecutor()
55
55
final AtomicReference <Object > dataInOnOperatorError = new AtomicReference <>();
56
56
57
57
try {
58
-
59
- CountDownLatch hookLatch = new CountDownLatch (1 );
58
+ CountDownLatch finallyLatch = new CountDownLatch ( 1 );
59
+ CountDownLatch inOnNextLatch = new CountDownLatch (1 );
60
60
61
61
Hooks .onOperatorError ((t , d ) -> {
62
62
throwableInOnOperatorError .set (t );
63
63
dataInOnOperatorError .set (d );
64
- hookLatch .countDown ();
65
64
return t ;
66
65
});
67
66
@@ -73,22 +72,25 @@ public void rejectedExecutionExceptionOnDataSignalExecutor()
73
72
.publishOn (fromExecutorService (executor ))
74
73
.doOnNext (s -> {
75
74
try {
75
+ inOnNextLatch .countDown ();
76
76
latch .await ();
77
77
}
78
78
catch (InterruptedException e ) {
79
79
}
80
80
})
81
81
.publishOn (fromExecutor (executor ))
82
+ .doFinally (s -> finallyLatch .countDown ())
82
83
.subscribe (assertSubscriber );
83
84
85
+ inOnNextLatch .await ();
84
86
executor .shutdownNow ();
85
87
88
+ finallyLatch .await ();
89
+
86
90
assertSubscriber .assertNoValues ()
87
- .assertNoError ( )
91
+ .assertError ( RejectedExecutionException . class )
88
92
.assertNotComplete ();
89
93
90
- hookLatch .await ();
91
-
92
94
assertThat (throwableInOnOperatorError .get ()).isInstanceOf (RejectedExecutionException .class );
93
95
assertThat (data ).isSameAs (dataInOnOperatorError .get ());
94
96
}
@@ -109,13 +111,12 @@ public void rejectedExecutionExceptionOnErrorSignalExecutor()
109
111
final AtomicReference <Object > dataInOnOperatorError = new AtomicReference <>();
110
112
111
113
try {
112
-
113
- CountDownLatch hookLatch = new CountDownLatch (2 );
114
+ CountDownLatch finallyLatch = new CountDownLatch ( 1 );
115
+ CountDownLatch inOnNextLatch = new CountDownLatch (1 );
114
116
115
117
Hooks .onOperatorError ((t , d ) -> {
116
118
throwableInOnOperatorError .set (t );
117
119
dataInOnOperatorError .set (d );
118
- hookLatch .countDown ();
119
120
return t ;
120
121
});
121
122
@@ -127,23 +128,25 @@ public void rejectedExecutionExceptionOnErrorSignalExecutor()
127
128
.publishOn (fromExecutorService (executor ))
128
129
.doOnNext (s -> {
129
130
try {
131
+ inOnNextLatch .countDown ();
130
132
latch .await ();
131
133
}
132
134
catch (InterruptedException e ) {
133
135
throw Exceptions .propagate (exception );
134
136
}
135
137
})
136
138
.publishOn (fromExecutor (executor ))
139
+ .doFinally (s -> finallyLatch .countDown ())
137
140
.subscribe (assertSubscriber );
138
141
142
+ inOnNextLatch .await ();
139
143
executor .shutdownNow ();
140
144
145
+ finallyLatch .await ();
141
146
assertSubscriber .assertNoValues ()
142
- .assertNoError ( )
147
+ .assertError ( RejectedExecutionException . class )
143
148
.assertNotComplete ();
144
149
145
- hookLatch .await ();
146
-
147
150
assertThat (throwableInOnOperatorError .get ()).isInstanceOf (RejectedExecutionException .class );
148
151
assertThat (exception ).isSameAs (throwableInOnOperatorError .get ()
149
152
.getSuppressed ()[0 ]);
@@ -164,13 +167,12 @@ public void rejectedExecutionExceptionOnDataSignalExecutorService()
164
167
final AtomicReference <Object > dataInOnOperatorError = new AtomicReference <>();
165
168
166
169
try {
167
-
168
- CountDownLatch hookLatch = new CountDownLatch (1 );
170
+ CountDownLatch finallyLatch = new CountDownLatch ( 1 );
171
+ CountDownLatch inOnNextLatch = new CountDownLatch (1 );
169
172
170
173
Hooks .onOperatorError ((t , d ) -> {
171
174
throwableInOnOperatorError .set (t );
172
175
dataInOnOperatorError .set (d );
173
- hookLatch .countDown ();
174
176
return t ;
175
177
});
176
178
@@ -182,22 +184,25 @@ public void rejectedExecutionExceptionOnDataSignalExecutorService()
182
184
.publishOn (fromExecutorService (executor ))
183
185
.doOnNext (s -> {
184
186
try {
187
+ inOnNextLatch .countDown ();
185
188
latch .await ();
186
189
}
187
190
catch (InterruptedException e ) {
188
191
}
189
192
})
190
193
.publishOn (fromExecutorService (executor ))
194
+ .doFinally (s -> finallyLatch .countDown ())
191
195
.subscribe (assertSubscriber );
192
196
197
+ inOnNextLatch .await ();
198
+
193
199
executor .shutdownNow ();
194
200
201
+ finallyLatch .await ();
195
202
assertSubscriber .assertNoValues ()
196
- .assertNoError ( )
203
+ .assertError ( RejectedExecutionException . class )
197
204
.assertNotComplete ();
198
205
199
- hookLatch .await ();
200
-
201
206
assertThat (throwableInOnOperatorError .get ()).isInstanceOf (RejectedExecutionException .class );
202
207
assertThat (data ).isSameAs (dataInOnOperatorError .get ());
203
208
}
@@ -218,13 +223,12 @@ public void rejectedExecutionExceptionOnErrorSignalExecutorService()
218
223
final AtomicReference <Object > dataInOnOperatorError = new AtomicReference <>();
219
224
220
225
try {
221
-
222
- CountDownLatch hookLatch = new CountDownLatch (2 );
226
+ CountDownLatch finallyLatch = new CountDownLatch ( 1 );
227
+ CountDownLatch inOnNextLatch = new CountDownLatch (1 );
223
228
224
229
Hooks .onOperatorError ((t , d ) -> {
225
230
throwableInOnOperatorError .set (t );
226
231
dataInOnOperatorError .set (d );
227
- hookLatch .countDown ();
228
232
return t ;
229
233
});
230
234
@@ -236,23 +240,26 @@ public void rejectedExecutionExceptionOnErrorSignalExecutorService()
236
240
.publishOn (fromExecutorService (executor ))
237
241
.doOnNext (s -> {
238
242
try {
243
+ inOnNextLatch .countDown ();
239
244
latch .await ();
240
245
}
241
246
catch (InterruptedException e ) {
242
247
throw Exceptions .propagate (exception );
243
248
}
244
249
})
245
250
.publishOn (fromExecutorService (executor ))
251
+ .doFinally (s -> finallyLatch .countDown ())
246
252
.subscribe (assertSubscriber );
247
253
254
+ inOnNextLatch .await ();
255
+
248
256
executor .shutdownNow ();
249
257
258
+ finallyLatch .await ();
250
259
assertSubscriber .assertNoValues ()
251
- .assertNoError ( )
260
+ .assertError ( RejectedExecutionException . class )
252
261
.assertNotComplete ();
253
262
254
- hookLatch .await ();
255
-
256
263
assertThat (throwableInOnOperatorError .get ()).isInstanceOf (RejectedExecutionException .class );
257
264
assertThat (exception ).isSameAs (throwableInOnOperatorError .get ()
258
265
.getSuppressed ()[0 ]);
0 commit comments