Skip to content

Commit

Permalink
Merge #3156 into 3.5.0-M6
Browse files Browse the repository at this point in the history
Signed-off-by: Oleh Dokuka <odokuka@vmware.com>
Signed-off-by: OlegDokuka <odokuka@vmware.com>
  • Loading branch information
Oleh Dokuka committed Aug 16, 2022
2 parents c747f80 + 7f6f65f commit 8a31886
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
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 @@ -8438,6 +8438,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 @@ -4299,6 +4299,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
30 changes: 28 additions & 2 deletions reactor-core/src/test/java/reactor/core/publisher/HooksTest.java
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();
}
}
}

0 comments on commit 8a31886

Please sign in to comment.