Hi,

is it possible that the regexp get executed in code called from a
setTimeout / setInterval or XMLHttpRequest? In this case, with
HtmlUnit-1.14 this occurs a separate thread and thread have a smaller
heap allocated than the "main" thread. This would explain why you
couldn't reproduce it. I guess that if you run your test in a separate
thread you will be able to get the expected Error.

Cheers,
Marc.
-- 
Blog: http://mguillem.wordpress.com


ruel loehr wrote:
> Fixed by upping the stack size.   I guess that section of the code has a
> heavy footprint.
> 
> 
> ruel loehr wrote:
>> We are having some problems using the latest webtest release with dwr and
>> javascript templates.
>>
>> JDK is 1.5.0.11.
>>
>> Initially, mark pointed us too some improvements made on htmlunit trunk
>> for regex processing.
>>
>> I checked out html unit 1.14 tagged release and ported the trunk change
>> for HTMLUnitRegexProxy to that branch.  Everything worked fine for a bit,
>> until our developers introduced dwr onto a second page.   Our stack
>> overflow errors then reappeared.
>>
>>     [sleep] Exception in thread "HtmlUnit Managed Thread #7:
>> XMLHttpRequest.send" java.lang.StackOverflowError
>>     [sleep]          at
>> java.util.regex.Pattern$Curly.match(Pattern.java:4190)
>>
>> I've hacked around at the htmlunit source, putting in a bunch of debug
>> statements to try and narrow the problem.
>>
>>     [sleep]  INFO
>> (com.gargoylesoftware.htmlunit.javascript.regexp.HtmlUnitRegExpProxy$RegExpData)
>> - After escapeJSCurly re is  ^(\s*\S*(\s+\S+)*)\s*$
>>     [sleep]  INFO
>> (com.gargoylesoftware.htmlunit.javascript.regexp.HtmlUnitRegExpProxy) -
>> Pattern compiled
>>     [sleep]  INFO
>> (com.gargoylesoftware.htmlunit.javascript.regexp.HtmlUnitRegExpProxy) - We
>> are now calling pattern matcher with string: {var hourTypeIndicators =
>> ["Branch Working Hours","Specific Hours","Not Available"]}
>>     [sleep] {var hourValues =
>> ["01","02","03","04","05","06","07","08","09","10","11"]}
>>     [sleep] {var minuteValues = ["00","30"]}
>>     [sleep] {var ampmValues = ["AM","PM"]}
>>     [sleep] {var timeWindowSizes = [1, 2, 3,4, 5, 6,7, 8, 9,10, 11, 12,13,
>> 14, 15,16,17, 18, 19,20, 21, 22,23,24]}
>>     [sleep] {if schedulingConfig != null}
>>     [sleep]  {if (schedulingConfig.isBranchView)}
>>
>>    I SNIPPED some the code which gets output here, it's a big javascript
>> template.
>>
>>     [sleep]
>>     [sleep]
>>     [sleep]  INFO
>> (com.gargoylesoftware.htmlunit.javascript.regexp.HtmlUnitRegExpProxy) -
>> The matcher is created
>>     [sleep]  INFO
>> (com.gargoylesoftware.htmlunit.javascript.regexp.HtmlUnitRegExpProxy) -
>> Calling replaceAll on the matcher with replacemetn : $1
>>     [sleep] Exception in thread "HtmlUnit Managed Thread #7:
>> XMLHttpRequest.send" java.lang.StackOverflowError
>>     [sleep]          at
>> java.util.regex.Pattern$Curly.match(Pattern.java:4190)
>>
>> Now the interesting part.  I forced HTMLUnit to write out the the context
>> string, the regex pattern and the flags to 3 respective files.   Then I
>> wrote a small test class to simulate the behavior.
>>
>> public static void main(String[] args) {
>>             // TODO Auto-generated method stub
>>
>>         Regexp regexp = new Regexp("^(\\s*\\S*(\\s+\\S+)*)\\s*$");
>>
>>         String thisString= null;
>>
>>         byte b[];
>>             try {
>>                   FileInputStream fis = new
>> FileInputStream("c:\\string.txt");
>>                   int x= fis.available();
>>                   b = new byte[x];
>>
>>                   fis.read(b);
>>                   thisString = new String(b);
>>
>>             } catch (FileNotFoundException e) {
>>                   // TODO Auto-generated catch block
>>                   e.printStackTrace();
>>             } catch (IOException e) {
>>                   // TODO Auto-generated catch block
>>                   e.printStackTrace();
>>             }
>>
>>          System.out.println("About to compile a pattern");
>>          System.out.println("Regexp is " + regexp.toString());
>>
>>          final Pattern pattern = Pattern.compile(regexp.toString(), 0 );
>>          System.out.println("Pattern compiled");
>>          final Matcher matcher = pattern.matcher(thisString);
>>         System.out.println("The matcher is created ");
>>         String done = matcher.replaceAll("$1");
>>
>>       }
>>
>> I can't get it to fail.    Is the NativeRegExp class coming into play
>> somehow and causing this bug?  I haven't found a way to instantiate it in
>> my test.....
>>
>>
>> Thanks!
>> Ruel Loehr
>>
>>
>>
>>
>>
>>
> 

_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest

Reply via email to