-
CSR
-
Resolution: Approved
-
P4
-
None
-
behavioral
-
low
-
-
SE
Summary
Change the constructor of javax.management.MBeanOperationInfo.MBeanOperationInfo
throw an llegalArgumentException if the impact argument is not among the defined values INFO, ACTION, ACTION_INFO, or UNKNOWN.
Problem
javax.management.MBeanOperationInfo.MBeanOperationInfo
constructor accepts any integer value as impact.
Solution
Added validation for impact
parameter of javax.management.MBeanOperationInfo.MBeanOperationInfo
constructor.
MBeanOperationInfo throws new IllegalArgumentException if impact provided is not among INFO, ACTION, ACTION_INFO, UNKNOWN
Specification
--- old/src/java.management/share/classes/javax/management/MBeanOperationInfo.java 2017-11-08 23:19:02.156362000 +0530
+++ new/src/java.management/share/classes/javax/management/MBeanOperationInfo.java 2017-11-08 23:19:01.160362000 +0530
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, 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
@@ -146,6 +146,9 @@
* @param descriptor The descriptor for the operation. This may be null
* which is equivalent to an empty descriptor.
*
+ * @throws IllegalArgumentException if {@code impact} is not one of
+ * {@linkplain #ACTION}, {@linkplain #ACTION_INFO}, {@linkplain #INFO} or {@linkplain #UNKNOWN}.
+ *
* @since 1.6
*/
public MBeanOperationInfo(String name,
@@ -157,6 +160,12 @@
super(name, description, descriptor);
+ if (impact < INFO || impact > UNKNOWN) {
+ throw new IllegalArgumentException("Argument impact can only be "
+ + "one of ACTION, ACTION_INFO, "
+ + "INFO, or UNKNOWN" + " given value is :" + impact);
+ }
+
if (signature == null || signature.length == 0)
signature = MBeanParameterInfo.NO_PARAMS;
else
@@ -259,8 +268,7 @@
case ACTION: impactString = "action"; break;
case ACTION_INFO: impactString = "action/info"; break;
case INFO: impactString = "info"; break;
- case UNKNOWN: impactString = "unknown"; break;
- default: impactString = "(" + getImpact() + ")";
+ default: impactString = "unknown";
}
return getClass().getName() + "[" +
"description=" + getDescription() + ", " +
- csr of
-
JDK-8024352 MBeanOperationInfo accepts any int value as "impact"
-
- Resolved
-
- duplicates
-
JDK-8352739 Hotspot-8 missing parameter check in javax.management.MBeanOperationInfo
-
- Closed
-