commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcus Deluigi <mdelu...@student.ethz.ch>
Subject Re: Javaflow: Bug in Continuation.getContext();?
Date Wed, 02 Aug 2006 16:27:52 GMT
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: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message