DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24842>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24842 java.lang.NullPointerException in first test -- thread synchronization prob? Summary: java.lang.NullPointerException in first test -- thread synchronization prob? Product: Cactus Version: 1.5-rc1 Platform: PC OS/Version: Other Status: NEW Severity: Normal Priority: Other Component: Framework AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] 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 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
