mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
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
2 changed files with 25 additions and 16 deletions
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -619,10 +619,12 @@ public abstract class URLConnection {
|
|||
* missing or malformed.
|
||||
*/
|
||||
public int getHeaderFieldInt(String name, int Default) {
|
||||
String value = getHeaderField(name);
|
||||
try {
|
||||
return Integer.parseInt(value);
|
||||
} catch (Exception e) { }
|
||||
final String value = getHeaderField(name);
|
||||
if (value != null) {
|
||||
try {
|
||||
return Integer.parseInt(value);
|
||||
} catch (NumberFormatException e) { }
|
||||
}
|
||||
return Default;
|
||||
}
|
||||
|
||||
|
@ -642,10 +644,12 @@ public abstract class URLConnection {
|
|||
* @since 1.7
|
||||
*/
|
||||
public long getHeaderFieldLong(String name, long Default) {
|
||||
String value = getHeaderField(name);
|
||||
try {
|
||||
return Long.parseLong(value);
|
||||
} catch (Exception e) { }
|
||||
final String value = getHeaderField(name);
|
||||
if (value != null) {
|
||||
try {
|
||||
return Long.parseLong(value);
|
||||
} catch (NumberFormatException e) { }
|
||||
}
|
||||
return Default;
|
||||
}
|
||||
|
||||
|
@ -667,10 +671,12 @@ public abstract class URLConnection {
|
|||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public long getHeaderFieldDate(String name, long Default) {
|
||||
String value = getHeaderField(name);
|
||||
try {
|
||||
return Date.parse(value);
|
||||
} catch (Exception e) { }
|
||||
final String value = getHeaderField(name);
|
||||
if (value != null) {
|
||||
try {
|
||||
return Date.parse(value);
|
||||
} catch (Exception e) { }
|
||||
}
|
||||
return Default;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue