From 9f2e076809a6a83701aaef12d905acfbe0b9ddb2 Mon Sep 17 00:00:00 2001 From: johannes karoff Date: Wed, 8 Nov 2023 01:16:30 +0100 Subject: [PATCH] fix Cancelable.Builder if it is cancelled while subscribing --- colibri/src/main/scala/colibri/Cancelable.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/colibri/src/main/scala/colibri/Cancelable.scala b/colibri/src/main/scala/colibri/Cancelable.scala index adc9e074..24225559 100644 --- a/colibri/src/main/scala/colibri/Cancelable.scala +++ b/colibri/src/main/scala/colibri/Cancelable.scala @@ -46,7 +46,11 @@ object Cancelable { def unsafeAdd(subscription: () => Cancelable): Unit = if (buffer != null) { val cancelable = subscription() - buffer.push(cancelable) + if (buffer == null) { + cancelable.cancel() + } else { + buffer.push(cancelable) + } () }