8297211: Expensive fillInStackTrace operation in HttpURLConnection.getOutputStream0 when no content-length in response
Reviewed-by: simonis, dfuchs
This commit is contained in:
parent
5a45c25151
commit
392ac7055d
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1995, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -619,10 +619,12 @@ public abstract class URLConnection {
|
|||||||
* missing or malformed.
|
* missing or malformed.
|
||||||
*/
|
*/
|
||||||
public int getHeaderFieldInt(String name, int Default) {
|
public int getHeaderFieldInt(String name, int Default) {
|
||||||
String value = getHeaderField(name);
|
final String value = getHeaderField(name);
|
||||||
|
if (value != null) {
|
||||||
try {
|
try {
|
||||||
return Integer.parseInt(value);
|
return Integer.parseInt(value);
|
||||||
} catch (Exception e) { }
|
} catch (NumberFormatException e) { }
|
||||||
|
}
|
||||||
return Default;
|
return Default;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -642,10 +644,12 @@ public abstract class URLConnection {
|
|||||||
* @since 1.7
|
* @since 1.7
|
||||||
*/
|
*/
|
||||||
public long getHeaderFieldLong(String name, long Default) {
|
public long getHeaderFieldLong(String name, long Default) {
|
||||||
String value = getHeaderField(name);
|
final String value = getHeaderField(name);
|
||||||
|
if (value != null) {
|
||||||
try {
|
try {
|
||||||
return Long.parseLong(value);
|
return Long.parseLong(value);
|
||||||
} catch (Exception e) { }
|
} catch (NumberFormatException e) { }
|
||||||
|
}
|
||||||
return Default;
|
return Default;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -667,10 +671,12 @@ public abstract class URLConnection {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public long getHeaderFieldDate(String name, long Default) {
|
public long getHeaderFieldDate(String name, long Default) {
|
||||||
String value = getHeaderField(name);
|
final String value = getHeaderField(name);
|
||||||
|
if (value != null) {
|
||||||
try {
|
try {
|
||||||
return Date.parse(value);
|
return Date.parse(value);
|
||||||
} catch (Exception e) { }
|
} catch (Exception e) { }
|
||||||
|
}
|
||||||
return Default;
|
return Default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1932,9 +1932,12 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String contentLengthVal = responses.findValue("content-length");
|
||||||
|
if (contentLengthVal != null) {
|
||||||
try {
|
try {
|
||||||
cl = Long.parseLong(responses.findValue("content-length"));
|
cl = Long.parseLong(contentLengthVal);
|
||||||
} catch (Exception exc) { };
|
} catch (NumberFormatException nfe) { }
|
||||||
|
}
|
||||||
|
|
||||||
if (method.equals("HEAD") || cl == 0 ||
|
if (method.equals("HEAD") || cl == 0 ||
|
||||||
respCode == HTTP_NOT_MODIFIED ||
|
respCode == HTTP_NOT_MODIFIED ||
|
||||||
|
Loading…
x
Reference in New Issue
Block a user