From: <mgu...@us...> - 2013-01-07 11:32:39
|
Revision: 7940 http://sourceforge.net/p/htmlunit/code/7940 Author: mguillem Date: 2013-01-07 11:32:36 +0000 (Mon, 07 Jan 2013) Log Message: ----------- discard HttpClient instance in case of Error as workaround for leak with connections Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2013-01-07 07:42:55 UTC (rev 7939) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2013-01-07 11:32:36 UTC (rev 7940) @@ -181,6 +181,16 @@ throw s; } } + catch (final Error e) { + // in case a StackOverflowError occurs while the connection is leased, it won't get released. + // Calling code may catch the StackOverflowError, but due to the leak, the httpClient_ may + // come out of connections and throw a ConnectionPoolTimeoutException. + // => best solution, discard the HttpClient instance. + synchronized (this) { + httpClient_ = null; + } + throw e; + } final DownloadedContent downloadedBody = downloadResponseBody(httpResponse); final long endTime = System.currentTimeMillis(); |