use of io.servicetalk.concurrent.internal.DuplicateSubscribeException in project servicetalk by apple.
the class PublisherProcessor method handleSubscribe.
@Override
protected void handleSubscribe(final Subscriber<? super T> subscriber) {
final DelayedSubscription delayedSubscription = new DelayedSubscription();
try {
subscriber.onSubscribe(delayedSubscription);
} catch (Throwable t) {
handleExceptionFromOnSubscribe(subscriber, t);
return;
}
if (consumerUpdater.compareAndSet(this, null, new SubscriberProcessorSignalsConsumer<>(subscriber))) {
try {
delayedSubscription.delayedSubscription(this);
tryEmitSignals();
} catch (Throwable t) {
LOGGER.error("Unexpected error while delivering signals to the subscriber {}", subscriber, t);
}
} else {
ProcessorSignalsConsumer<? super T> existingConsumer = this.consumer;
assert existingConsumer != null;
@SuppressWarnings("unchecked") final Subscriber<? super T> existingSubscriber = existingConsumer instanceof PublisherProcessor.SubscriberProcessorSignalsConsumer ? ((SubscriberProcessorSignalsConsumer<T>) existingConsumer).subscriber : null;
safeOnError(subscriber, new DuplicateSubscribeException(existingSubscriber, subscriber));
}
}
use of io.servicetalk.concurrent.internal.DuplicateSubscribeException in project servicetalk by apple.
the class NettyChannelPublisher method subscribe0.
private void subscribe0(Subscriber<? super T> subscriber) {
SubscriptionImpl subscription = this.subscription;
if (subscription != null) {
deliverErrorFromSource(subscriber, new DuplicateSubscribeException(subscription.associatedSub, subscriber));
} else {
assert requestCount == 0;
subscription = new SubscriptionImpl(subscriber);
this.subscription = subscription;
subscriber.onSubscribe(subscription);
// In absence of the below, any subsequent Subscriber will not get any fatal error.
if (subscription == this.subscription && !processPending(subscription) && (fatalError != null && !hasQueuedSignals())) {
// We are already on the eventloop, so we are sure that nobody else is emitting to the Subscriber.
emitError(subscription, fatalError);
}
}
}
Aggregations