8297211: Expensive fillInStackTrace operation in HttpURLConnection.getOutputStream0 when no content-length in response

Reviewed-by: simonis, dfuchs
This commit is contained in:
Jaikiran Pai 2022-11-22 01:48:39 +00:00
parent 5a45c25151
commit 392ac7055d
2 changed files with 25 additions and 16 deletions

View file

@ -1932,9 +1932,12 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
continue;
}
try {
cl = Long.parseLong(responses.findValue("content-length"));
} catch (Exception exc) { };
final String contentLengthVal = responses.findValue("content-length");
if (contentLengthVal != null) {
try {
cl = Long.parseLong(contentLengthVal);
} catch (NumberFormatException nfe) { }
}
if (method.equals("HEAD") || cl == 0 ||
respCode == HTTP_NOT_MODIFIED ||