8040837: Avoid provoking NFEs when initializing InetAddrCachePolicy
Co-authored-by: Claes Redestad <claes.redestad@oracle.com> Reviewed-by: mduigou
This commit is contained in:
parent
ebe813fbb0
commit
17a8cfd9e7
@ -84,19 +84,31 @@ public final class InetAddressCachePolicy {
|
|||||||
* Initialize
|
* Initialize
|
||||||
*/
|
*/
|
||||||
static {
|
static {
|
||||||
Integer tmp = null;
|
|
||||||
|
|
||||||
try {
|
Integer tmp = java.security.AccessController.doPrivileged(
|
||||||
tmp = new Integer(
|
new PrivilegedAction<Integer>() {
|
||||||
java.security.AccessController.doPrivileged (
|
public Integer run() {
|
||||||
new PrivilegedAction<String>() {
|
try {
|
||||||
public String run() {
|
String tmpString = Security.getProperty(cachePolicyProp);
|
||||||
return Security.getProperty(cachePolicyProp);
|
if (tmpString != null) {
|
||||||
}
|
return Integer.valueOf(tmpString);
|
||||||
}));
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException ignored) {
|
||||||
// ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
String tmpString = System.getProperty(cachePolicyPropFallback);
|
||||||
|
if (tmpString != null) {
|
||||||
|
return Integer.decode(tmpString);
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException ignored) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (tmp != null) {
|
if (tmp != null) {
|
||||||
cachePolicy = tmp.intValue();
|
cachePolicy = tmp.intValue();
|
||||||
if (cachePolicy < 0) {
|
if (cachePolicy < 0) {
|
||||||
@ -104,35 +116,36 @@ public final class InetAddressCachePolicy {
|
|||||||
}
|
}
|
||||||
propertySet = true;
|
propertySet = true;
|
||||||
} else {
|
} else {
|
||||||
tmp = java.security.AccessController.doPrivileged
|
/* No properties defined for positive caching. If there is no
|
||||||
(new sun.security.action.GetIntegerAction(cachePolicyPropFallback));
|
* security manager then use the default positive cache value.
|
||||||
if (tmp != null) {
|
*/
|
||||||
cachePolicy = tmp.intValue();
|
if (System.getSecurityManager() == null) {
|
||||||
if (cachePolicy < 0) {
|
cachePolicy = DEFAULT_POSITIVE;
|
||||||
cachePolicy = FOREVER;
|
|
||||||
}
|
|
||||||
propertySet = true;
|
|
||||||
} else {
|
|
||||||
/* No properties defined for positive caching. If there is no
|
|
||||||
* security manager then use the default positive cache value.
|
|
||||||
*/
|
|
||||||
if (System.getSecurityManager() == null) {
|
|
||||||
cachePolicy = DEFAULT_POSITIVE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
tmp = java.security.AccessController.doPrivileged (
|
||||||
|
new PrivilegedAction<Integer>() {
|
||||||
|
public Integer run() {
|
||||||
|
try {
|
||||||
|
String tmpString = Security.getProperty(negativeCachePolicyProp);
|
||||||
|
if (tmpString != null) {
|
||||||
|
return Integer.valueOf(tmpString);
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException ignored) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
tmp = new Integer(
|
String tmpString = System.getProperty(negativeCachePolicyPropFallback);
|
||||||
java.security.AccessController.doPrivileged (
|
if (tmpString != null) {
|
||||||
new PrivilegedAction<String>() {
|
return Integer.decode(tmpString);
|
||||||
public String run() {
|
}
|
||||||
return Security.getProperty(negativeCachePolicyProp);
|
} catch (NumberFormatException ignored) {
|
||||||
}
|
// Ignore
|
||||||
}));
|
}
|
||||||
} catch (NumberFormatException e) {
|
return null;
|
||||||
// ignore
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
if (tmp != null) {
|
if (tmp != null) {
|
||||||
negativeCachePolicy = tmp.intValue();
|
negativeCachePolicy = tmp.intValue();
|
||||||
@ -140,16 +153,6 @@ public final class InetAddressCachePolicy {
|
|||||||
negativeCachePolicy = FOREVER;
|
negativeCachePolicy = FOREVER;
|
||||||
}
|
}
|
||||||
propertyNegativeSet = true;
|
propertyNegativeSet = true;
|
||||||
} else {
|
|
||||||
tmp = java.security.AccessController.doPrivileged
|
|
||||||
(new sun.security.action.GetIntegerAction(negativeCachePolicyPropFallback));
|
|
||||||
if (tmp != null) {
|
|
||||||
negativeCachePolicy = tmp.intValue();
|
|
||||||
if (negativeCachePolicy < 0) {
|
|
||||||
negativeCachePolicy = FOREVER;
|
|
||||||
}
|
|
||||||
propertyNegativeSet = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user