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

Reactor plugin will cause app error #8539

Closed
will-zdu opened this issue May 22, 2023 · 1 comment · Fixed by #8571
Closed

Reactor plugin will cause app error #8539

will-zdu opened this issue May 22, 2023 · 1 comment · Fixed by #8571
Labels
bug Something isn't working

Comments

@will-zdu
Copy link

Describe the bug
A clear and concise description of what the bug is.
ound error
Caused by: java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread single-1
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:83)
at reactor.core.publisher.Mono.block(Mono.java:1707)
at com.example.examplereactor.TestHook1.lambda$main$0(TestHook1.java:46)
at reactor.core.publisher.FluxStream.subscribe(FluxStream.java:48)
at reactor.core.publisher.InternalFluxOperator.subscribe(InternalFluxOperator.java:62)
at reactor.core.publisher.FluxSubscribeOn$SubscribeOnSubscriber.run(FluxSubscribeOn.java:194)
at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:84)
at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:37)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

Steps to reproduce
If possible, provide a recipe for reproducing the error.

package app.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.CoreSubscriber;
import reactor.core.Scannable;
import reactor.core.publisher.Hooks;
import reactor.core.publisher.Mono;
import reactor.core.publisher.Operators;
import reactor.core.scheduler.Schedulers;

import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import java.util.function.BiFunction;

public class TestHook {

    private static final Logger logger = LoggerFactory.getLogger(TestHook.class);

    static{
        try{
            Hooks.onEachOperator("testHook", Operators.lift(new Lifter<>()));
        }catch (Throwable ignored){
        }
    }


    public static class Lifter<T>
            implements BiFunction<Scannable, CoreSubscriber<? super T>, CoreSubscriber<? super T>> {

        /** Holds reference to strategy to prevent it from being collected. */

        @Override
        public CoreSubscriber<? super T> apply(Scannable publisher, CoreSubscriber<? super T> sub) {
            return sub;
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Callable<String> callable = () -> {
            logger.info("Operation enter call1: ");
            Mono.just("test1").block();
            return "call1";
        };


        Mono.defer(() -> Mono.fromCallable(callable)
                             .publishOn(Schedulers.elastic())
                             .flatMap(source -> {
                                 logger.info("Again enter map :{} ", source);
                                 return Mono.just(source);
                             })).subscribeOn(Schedulers.single()).subscribe();


        TimeUnit.SECONDS.sleep(3);
    }
}

What did you expect to see?
A clear and concise description of what you expected to see.
no error found
What did you see instead?
A clear and concise description of what you saw instead.
reactor/reactor-core#3450
reactor/reactor-core#3452
What version are you using?
(e.g., v0.9.0, 393e4a2, etc)
anyone will be reported it ,it's a bug of reactor
Environment
Compiler: (e.g., "AdoptOpenJDK 11.0.6")
OS: (e.g., "Ubuntu 20.04")
Runtime (if different from JDK above): (e.g., "Oracle JRE 8u251")
OS (if different from OS compiled on): (e.g., "Windows Server 2019")

Additional context
Add any other context about the problem here.
I have add a bug to reactor ,but they just suggest me to change my code ,but as javaagent developer ,we can not control app's code

@will-zdu will-zdu added the bug Something isn't working label May 22, 2023
@mateuszrzeszutek
Copy link
Member

Hey @will-zdu ,

While I changed our instrumentation to be slightly less impactful in #8571, the Reactor maintainers are right and the Mono.just(...).block() call in your Callable should not really be there in the first place. Consider changing your application code and fixing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants