[Htmlparser-developer] testThreadSafety error
Brought to you by:
derrickoswald
From: Derrick O. <Der...@ro...> - 2003-03-31 03:24:06
|
Somik, Running testThreadSafety() can give different errors or no errors at all depending on the run (typical of race conditions). The errors might only crop up on SMP systems (I've got a dual CPU). When it fails, the actual link appears empty even though the link text is not (see the debug outputs below): id = 5 link = "" linkText = " Server: sf-web2 \t SourceForge.net: Modify: 711073 - HTMLTagParser not threadsafe as a static variable in HTMLTag\t\t\tfunction help_window(helpurl) {\t\tHelpWin = window.open( \'http://sourceforge.net\' + helpurl,\'HelpWindow\',\'scrollbars=yes,resizable=yes,toolbar=no,height=400,width=400\');\t}\t// \t\t\t This is temp javascript for the jump button. If we could actually have a jump script on the server side that would be ideal \tfunction jump(targ,selObj,restore){ //v3.0\tif (selObj.options[selObj.selectedIndex].value) \t\teval(targ+\".location=\'\"+selObj.options[selObj.selectedIndex].value+\"\'\");\tif (restore) selObj.selectedIndex=0;\t}\t//" result = false Here's some example JUnit dumps: ******************************************************************************************************** junit.framework.AssertionFailedError: Thread 55, link 1: EXPECTED result has 35 extra characters at the end. They are : Position : 0 , Code = 104 Position : 1 , Code = 116 Position : 2 , Code = 116 Position : 3 , Code = 112 <snip> Position : 33 , Code = 109 Position : 34 , Code = 108 Mismatch of strings at char posn 0 String Expected upto mismatch = String Actual upto mismatch = String Expected MISMATCH CHARACTER = h, code = 104 **** COMPLETE STRING EXPECTED **** http://normallink.com/sometext.html **** COMPLETE STRING ACTUAL*** at org.htmlparser.tests.ParserTestCase.assertStringEquals(ParserTestCase.java:125) at org.htmlparser.tests.parserHelperTests.TagParserTest.testThreadSafety(TagParserTest.java:186) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ******************************************************************************************************** junit.framework.AssertionFailedError: Thread 26, link 2: EXPECTED result has 116 extra characters at the end. They are : Position : 0 , Code = 47 Position : 1 , Code = 99 Position : 2 , Code = 103 Position : 3 , Code = 105 <snip> Position : 114 , Code = 109 Position : 115 , Code = 108 Mismatch of strings at char posn 0 String Expected upto mismatch = String Actual upto mismatch = String Expected MISMATCH CHARACTER = /, code = 47 **** COMPLETE STRING EXPECTED **** /cgi-bin/view_search?query_text=postdate>20020701&txt_clr=White&bg_clr=Red&url=http://localhost/Testing/Report1.html **** COMPLETE STRING ACTUAL*** at org.htmlparser.tests.ParserTestCase.assertStringEquals(ParserTestCase.java:125) at org.htmlparser.tests.parserHelperTests.TagParserTest.testThreadSafety(TagParserTest.java:191) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) Hope this helps, Derrick Somik Raha wrote: > > testThreadSafety > > Thanks for reporting this - on my end this one's passing. I had left > one last variable in TagParser- and I thought it would affect Thread > safety. So I rigged up that test, but surprisingly it passed every > time on my end. Can you send me the failure message ? I might need to > rework TagParser again. > > |