8019292: Better Attribute Value Exceptions
Reviewed-by: dfuchs, dholmes, ahgross
This commit is contained in:
parent
10738dc298
commit
a3b45465c6
@ -25,6 +25,9 @@
|
|||||||
|
|
||||||
package javax.management;
|
package javax.management;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thrown when an invalid MBean attribute is passed to a query
|
* Thrown when an invalid MBean attribute is passed to a query
|
||||||
@ -41,17 +44,19 @@ public class BadAttributeValueExpException extends Exception {
|
|||||||
private static final long serialVersionUID = -3105272988410493376L;
|
private static final long serialVersionUID = -3105272988410493376L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @serial The attribute value that originated this exception
|
* @serial A string representation of the attribute that originated this exception.
|
||||||
|
* for example, the string value can be the return of {@code attribute.toString()}
|
||||||
*/
|
*/
|
||||||
private Object val;
|
private Object val;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an <CODE>BadAttributeValueExpException</CODE> with the specified Object.
|
* Constructs a BadAttributeValueExpException using the specified Object to
|
||||||
|
* create the toString() value.
|
||||||
*
|
*
|
||||||
* @param val the inappropriate value.
|
* @param val the inappropriate value.
|
||||||
*/
|
*/
|
||||||
public BadAttributeValueExpException (Object val) {
|
public BadAttributeValueExpException (Object val) {
|
||||||
this.val = val;
|
this.val = val == null ? null : val.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -62,4 +67,25 @@ public class BadAttributeValueExpException extends Exception {
|
|||||||
return "BadAttributeValueException: " + val;
|
return "BadAttributeValueException: " + val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
|
||||||
|
ObjectInputStream.GetField gf = ois.readFields();
|
||||||
|
Object valObj = gf.get("val", null);
|
||||||
|
|
||||||
|
if (valObj == null) {
|
||||||
|
val = null;
|
||||||
|
} else if (valObj instanceof String) {
|
||||||
|
val= valObj;
|
||||||
|
} else if (System.getSecurityManager() == null
|
||||||
|
|| valObj instanceof Long
|
||||||
|
|| valObj instanceof Integer
|
||||||
|
|| valObj instanceof Float
|
||||||
|
|| valObj instanceof Double
|
||||||
|
|| valObj instanceof Byte
|
||||||
|
|| valObj instanceof Short
|
||||||
|
|| valObj instanceof Boolean) {
|
||||||
|
val = valObj.toString();
|
||||||
|
} else { // the serialized object is from a version without JDK-8019292 fix
|
||||||
|
val = System.identityHashCode(valObj) + "@" + valObj.getClass().getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user