7146776: deadlock between URLStreamHandler.getHostAddress and file.Handler.openconnection

Reviewed-by: alanb, chegar
This commit is contained in:
Jaikiran Pai 2021-01-18 11:53:22 +00:00
parent 61292be755
commit db9c114d40
2 changed files with 30 additions and 20 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2021, 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
@ -443,23 +443,8 @@ public abstract class URLStreamHandler {
* IP address.
* @since 1.3
*/
protected synchronized InetAddress getHostAddress(URL u) {
if (u.hostAddress != null)
return u.hostAddress;
String host = u.getHost();
if (host == null || host.isEmpty()) {
return null;
} else {
try {
u.hostAddress = InetAddress.getByName(host);
} catch (UnknownHostException ex) {
return null;
} catch (SecurityException se) {
return null;
}
}
return u.hostAddress;
protected InetAddress getHostAddress(URL u) {
return u.getHostAddress();
}
/**