2013-04-16 67 views
0

它看起來像一個過長的字符串造成如下因素的異常:的StackOverflowError在String.toLowerCase

Caused by: java.lang.StackOverflowError 
    at java.lang.String.toLowerCase(String.java:2496) 
    at com.gargoylesoftware.htmlunit.html.NamedAttrNodeMapImpl.fixName(DomElement.java:489) 
    at com.gargoylesoftware.htmlunit.html.NamedAttrNodeMapImpl.get(DomElement.java:602) 
    at com.gargoylesoftware.htmlunit.html.DomElement.getAttribute(DomElement.java:215) 
    at com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleDeclaration.getStyleMap(CSSStyleDeclaration.java:634) 
    at com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration.getStyleMap(ComputedCSSStyleDeclaration.java:243) 
    at com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleDeclaration.getStyleAttribute(CSSStyleDeclaration.java:472) 
    at com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration.getStyleAttribute(ComputedCSSStyleDeclaration.java:162) 
    at com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleDeclaration.jsxGet_position(CSSStyleDeclaration.java:4008) 
    at com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration.jsxGet_position(ComputedCSSStyleDeclaration.java:1304) 
    at com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration.getPositionWithInheritance(ComputedCSSStyleDeclaration.java:1883) 
    at com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration.getTop(ComputedCSSStyleDeclaration.java:1737) 
    at com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration.getTop(ComputedCSSStyleDeclaration.java:1769) 
    at com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration.getTop(ComputedCSSStyleDeclaration.java:1769) 
    at com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration.getTop(ComputedCSSStyleDeclaration.java:1769) 
    at com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration.getTop(ComputedCSSStyleDeclaration.java:1769) 
    at com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration.getTop(ComputedCSSStyleDeclaration.java:1769) 

我猜​​循環導致此問題。

什麼是字符串的物理限制? 我可以限制​​的環路檢測器嗎?

+0

那麼它自然可能是由過深的html結構和實現使用遞歸而不是迭代引起的。 – Esailija

+1

按字節長度限制字符串的長度,即2^31-1 – BlackJoker

+2

是否已經有一個關於此的錯誤? http://sourceforge.net/p/htmlunit/bugs/1233/ – emeraldjava

回答

1

原因是代碼中存在遞歸調用。請檢查。

在JVM的瞭解更深層次來解釋這個問題:Java虛擬機規範已經排除例外的兩種情況對於Java堆棧:

  1. Java堆棧允許全自動擴大,當它不能申請足夠的內存時它會拋出 OOM(OutOfMemory)錯誤。
  2. Java堆棧與堆棧幀構成,並且每一個Java 方法推框架,它會拋出StackOverflowError噹噹前線程的堆棧 深度比JVM的允許大。

也許幫助你:)

+0

'OutOfMemory'是**錯誤**,不是一個例外。你不能趕上'OutOfMemoryError' – gaborsch

+0

嗯,你可以捕捉它,這只是一個非常糟糕的主意。 –

+0

是啊,OOM是一個錯誤擴展VirtualMachineError。謝謝:) –