Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensures onLastAssembly does not break fusion chain #3156

Merged
merged 3 commits into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions reactor-core/src/main/java/reactor/core/publisher/Flux.java
Original file line number Diff line number Diff line change
Expand Up @@ -8445,6 +8445,10 @@ public final void subscribe(Subscriber<? super T> actual) {
CorePublisher publisher = Operators.onLastAssembly(this);
CoreSubscriber subscriber = Operators.toCoreSubscriber(actual);

if (subscriber instanceof Fuseable.QueueSubscription && this != publisher && this instanceof Fuseable && !(publisher instanceof Fuseable)) {
subscriber = new FluxHide.SuppressFuseableSubscriber<>(subscriber);
}

try {
if (publisher instanceof OptimizableOperator) {
OptimizableOperator operator = (OptimizableOperator) publisher;
Expand Down
4 changes: 4 additions & 0 deletions reactor-core/src/main/java/reactor/core/publisher/Mono.java
Original file line number Diff line number Diff line change
Expand Up @@ -4375,6 +4375,10 @@ public final void subscribe(Subscriber<? super T> actual) {
CorePublisher publisher = Operators.onLastAssembly(this);
CoreSubscriber subscriber = Operators.toCoreSubscriber(actual);

if (subscriber instanceof Fuseable.QueueSubscription && this != publisher && this instanceof Fuseable && !(publisher instanceof Fuseable)) {
subscriber = new FluxHide.SuppressFuseableSubscriber<>(subscriber);
}

try {
if (publisher instanceof OptimizableOperator) {
OptimizableOperator operator = (OptimizableOperator) publisher;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2021 VMware Inc. or its affiliates, All Rights Reserved.
* Copyright (c) 2016-2022 VMware Inc. or its affiliates, All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -70,7 +70,6 @@ public TestException(String message) {
}
}


@Test
public void staticActivationOfOperatorDebug() {
String oldProp = System.setProperty("reactor.trace.operatorStacktrace", "true");
Expand Down Expand Up @@ -142,6 +141,7 @@ public void onEachOperatorOneHookNoComposite() {
Function<? super Publisher<Object>, ? extends Publisher<Object>> hook = p -> p;
Hooks.onEachOperator(hook);


assertThat(Hooks.onEachOperatorHook).isSameAs(hook);
}

Expand Down Expand Up @@ -1254,4 +1254,30 @@ public void onComplete() {
}
};
}

// https://github.com/reactor/reactor-core/issues/3137
@Test
public void reproduceClassCastExceptionWithHooks() {
Hooks.onLastOperator(objectPublisher -> {
if (objectPublisher instanceof Mono) {
return Hooks.convertToMonoBypassingHooks(objectPublisher, false)
.doFinally(signalType -> {
});
} else {
return objectPublisher;
}
});

try {
Mono.just(1)
.flatMap(fsm -> Mono.just(1)
.doOnSubscribe(subscription -> {
}))
.doOnSubscribe(subscription -> {
})
.block();
} finally {
Hooks.resetOnLastOperator();
}
}
}