Skip to content

Commit 2d93a28

Browse files
author
Roger Riggs
committed
8232622: Technical debt in BadAttributeValueExpException
Reviewed-by: dfuchs, sspitsyn
1 parent b4ffe4d commit 2d93a28

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

src/java.management/share/classes/javax/management/BadAttributeValueExpException.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -48,7 +48,7 @@ public class BadAttributeValueExpException extends Exception {
4848
* for example, the string value can be the return of {@code attribute.toString()}
4949
*/
5050
@SuppressWarnings("serial") // See handling in constructor and readObject
51-
private Object val;
51+
private String val;
5252

5353
/**
5454
* Constructs a BadAttributeValueExpException using the specified Object to
@@ -72,19 +72,8 @@ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFound
7272
ObjectInputStream.GetField gf = ois.readFields();
7373
Object valObj = gf.get("val", null);
7474

75-
if (valObj == null) {
76-
val = null;
77-
} else if (valObj instanceof String) {
78-
val= valObj;
79-
} else if (System.getSecurityManager() == null
80-
|| valObj instanceof Long
81-
|| valObj instanceof Integer
82-
|| valObj instanceof Float
83-
|| valObj instanceof Double
84-
|| valObj instanceof Byte
85-
|| valObj instanceof Short
86-
|| valObj instanceof Boolean) {
87-
val = valObj.toString();
75+
if (valObj instanceof String || valObj == null) {
76+
val = (String)valObj;
8877
} else { // the serialized object is from a version without JDK-8019292 fix
8978
val = System.identityHashCode(valObj) + "@" + valObj.getClass().getName();
9079
}

0 commit comments

Comments
 (0)