puniverse / quasar

Fibers, Channels and Actors for the JVM
http://docs.paralleluniverse.co/quasar/
Other
4.56k stars 574 forks source link

fiber.get() in another fiber cause java.lang.NullPointerException #229

Closed tigerMoon closed 8 years ago

tigerMoon commented 8 years ago

the situation like this , in a fiber call another method,and in another method call fiber.get() method will cause this problem:

new Fiber<Void>((SuspendableRunnable) () -> {
            doSomething();
        }).inheritThreadLocals().start();

Then in the method use get() method:

@Suspendable
 doSomething(){
   // another fiber
    Fiber<R> fiber = new Fiber<R>() {
            @Override
            protected R run() throws SuspendExecution, InterruptedException {
                return companyTwoParam.apply(t1, t2);
            }
        };
        fiber.inheritThreadLocals();
        fiber.start();
        return fiber;

      fiber.get(); //  the problem is here
}

If i change the outside fiber to use thread ,it`s fine

Exception in Fiber "fiber-10000015" If this exception looks strange, perhaps you've forgotten to instrument a blocking method. Run your program with -Dco.paralleluniverse.fibers.verifyInstrumentation to catch the culprit!
java.lang.NullPointerException
  at co.paralleluniverse.strands.Strand.parkNanos(Strand.java:670)
  at co.paralleluniverse.strands.ConditionSynchronizer.awaitNanos(ConditionSynchronizer.java:79)
  at co.paralleluniverse.strands.dataflow.Val.get(Val.java:188)
  at co.paralleluniverse.fibers.Fiber.get(Fiber.java:1370)
  at co.paralleluniverse.fibers.Fiber.join(Fiber.java:1343)
  at co.paralleluniverse.strands.Strand.join(Strand.java:388)
  at 

I had use -Dco.paralleluniverse.fibers.verifyInstrumentation but there is no detect info,(it`s useful another situation)

In our product we use channel to transmit messages . but i also has some doubts about this.

pron commented 8 years ago

doSomething is not marked suspendable (with with a @Suspendable annotation or with throws SuspendExecution).

tigerMoon commented 8 years ago

I have marked it in my case , i will provide the exmaple project on github later . thank you

tigerMoon commented 8 years ago

than you pron . this is an invalid issue.