I am sorry, the code that I first send was not correct, meaning that it works fine. Here is a shorter, simpler and better example together with the stacktrace:

----------8<----------
import org.apache.commons.javaflow.Continuation;


class Test implements Runnable {

    public void run() {
        test();
    }

    public void test() {
        Context context = (Context) Continuation.getContext();
        if (context == null)
            System.out.println( "context is null" );
    }
}


public class javaflowTest {

    public static void main ( String[] args ) {
        Test thread = new Test();
        // this produces an error
        // thread.test();
        Continuation.startWith( thread );
    }

}
---------->8----------

Here is the output if you uncomment the line thread.test():
-----
Exception in thread "main" java.lang.NullPointerException
at org.apache.commons.javaflow.Continuation.getContext (Continuation.java:73)
        at Test.test(javaflowTest.java:11)
        at javaflowTest.main(javaflowTest.java:23)
-----

It works fine if you keep the comment, which proves that Test has been instrumented.

I think it would be nice (and reasonable) if there wasn't any exception and Continuation just returned a null value if it's not within a the threads context.


Greetings,
Marcus


On Aug 2, 2006, at 3:34 PM, Torsten Curdt wrote:

I have a Runnable class that is sometimes started with a context
object and sometimes without.

Alright ...the code looks ok and should work just fine.
You do instrument the "FlowRunnable2" but not the "jafaflowTest2" ?

When I call it without a context object, Continuation.getContext()
throws a NullPointerException, although the documentation states it
should just return a null value (which I think would be nice).

Is this a bug?

Please post the stacktrace.

cheers
--
Torsten

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to