@@ -160,10 +160,10 @@ private class PublisherCoroutine<in T>(
160
160
161
161
private fun unlockAndCheckCompleted () {
162
162
/*
163
- There is no sense to check completion before doing `unlock`, because completion might
164
- happen after this check and before `unlock` (see `signalCompleted` that does not do anything
165
- if it fails to acquire the lock that we are still holding).
166
- We have to recheck `isCompleted` after `unlock` anyway.
163
+ * There is no sense to check completion before doing `unlock`, because completion might
164
+ * happen after this check and before `unlock` (see `signalCompleted` that does not do anything
165
+ * if it fails to acquire the lock that we are still holding).
166
+ * We have to recheck `isCompleted` after `unlock` anyway.
167
167
*/
168
168
mutex.unlock()
169
169
// check isCompleted and and try to regain lock to signal completion
@@ -180,13 +180,17 @@ private class PublisherCoroutine<in T>(
180
180
if (cancelled) {
181
181
// If the parent had failed to handle our exception (handleJobException was invoked), then
182
182
// we must not loose this exception
183
- if (shouldHandleException && cause != null ) handleExceptionViaHandler(parentContext, cause)
183
+ if (shouldHandleException && cause != null ) {
184
+ handleExceptionViaHandler(parentContext, cause)
185
+ }
184
186
} else {
185
187
try {
186
- if (cause != null && cause !is CancellationException )
188
+ if (cause != null && cause !is CancellationException ) {
187
189
subscriber.onError(cause)
188
- else
190
+ }
191
+ else {
189
192
subscriber.onComplete()
193
+ }
190
194
} catch (e: Throwable ) {
191
195
handleExceptionViaHandler(parentContext, e)
192
196
}
@@ -261,4 +265,4 @@ private class PublisherCoroutine<in T>(
261
265
cancelled = true
262
266
super .cancel()
263
267
}
264
- }
268
+ }
0 commit comments