You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by "Vincent Massol (JIRA)" <ca...@jakarta.apache.org> on 2005/01/27 22:17:38 UTC

[jira] Updated: (CACTUS-74) java.lang.NullPointerException in first test -- thread synchronization prob?

     [ http://issues.apache.org/jira/browse/CACTUS-74?page=history ]

Vincent Massol updated CACTUS-74:
---------------------------------

    Fix Version:     (was: 1.7)

> java.lang.NullPointerException in first test -- thread synchronization prob?
> ----------------------------------------------------------------------------
>
>          Key: CACTUS-74
>          URL: http://issues.apache.org/jira/browse/CACTUS-74
>      Project: Cactus
>         Type: Bug
>   Components: Framework
>     Versions: 1.5-rc1
>  Environment: Operating System: Other
> Platform: PC
>     Reporter: Luiz-Otavio Zorzella

>
> I've written a fairly simple test case to test a servlet of mine. I log in, as
> required, and do a "doGet":
>     public void testOne () throws javax.servlet.ServletException {
>         ShowLinks servlet = new ShowLinks ();
>         servlet.init (config);
>         UserValue user = LFGetter.findUserByUsername("user");
>         Login.login (request, user);
>         servlet.doGet (request, response);
>     }
> This is the only test case in my Cactus suite. Right after deploying it to my
> jboss (jboss-3.2.2), and testing over the browser (with ServletTestRunner), I
> found out that Cactus reports a failure in this test. If I hit "reload" on the
> browser it reports success (and keeps on reporting sucess from then on). If I
> redeploy the EAR file, the same happens: the first time failure, afterwards,
> success. The failure happens with a Cactus NullPointerException (the Exception
> is at the framework itself, not in my servlet), which I narrowed down to this
> line in the method doGetResults():
>             writer.write(result.toXml());
> The reason for the exception is that "result" is null. "result" is populated
> right before that with this line:
>         WebTestResult result = (WebTestResult) (this.webImplicitObjects
>             .getServletContext().getAttribute(TEST_RESULTS));
> I've also figured that it is set in the servletContext by this line in doTest():
>         this.webImplicitObjects.getServletContext()
>             .setAttribute(TEST_RESULTS, result);
> That comes right after the servlet itself is excecuted, from the line:
>             testInstance.runBare();
> After more debugging, I figured out the this "runBare" will open a secondary
> thread, which will execute the "doGetResults()", while the "current thread" will
> be the one that continues the execution of "doTest()".
> ***************************************
> WHAT I THINK:
> The way I see it, the second thread should wait for the first one to set
> "TEST_RESULTS" before it executes "doGetResults()". And I think the reason it
> succeeds from the second test onwards is that this is cached from one run to the
> next.
> Please let me know if you need more information.
> Zorzella

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


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