Bugs item #886544, was opened at 2004-01-28 13:42
Message generated for change (Comment added) made by starksm
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=886544&group_id=22866
Category: JBossMX
Group: v3.2
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Jeff Haynie (jhaynie)
>Assigned to: Scott M Stark (starksm)
Summary: serialized ObjectName canonical value not equal
Initial Comment:
If you serialize an ObjectName and de-serialize it, the
canonical name (and toString()) are not equal - although
the object equality is true.
Example to program illustrate problem:
public class foo
{
public static void main (String args[])
{
try
{
ObjectName obj=new ObjectName
("vocalos:type=Service,foo=bar,bar=foo");
System.out.println(obj);
ByteArrayOutputStream bos=new
ByteArrayOutputStream();
ObjectOutputStream oos=new
ObjectOutputStream(bos);
oos.writeObject(obj);
ByteArrayInputStream bis=new
ByteArrayInputStream(bos.toByteArray());
ObjectInputStream ois=new ObjectInputStream
(bis);
ObjectName obj2 = (ObjectName)ois.readObject
();
// obj1 != obj2 (from a string value sense)
System.out.println(obj2);
System.out.println(obj.equals(obj2));
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
----------------------------------------------------------------------
>Comment By: Scott M Stark (starksm)
Date: 2004-01-28 15:26
Message:
Logged In: YES
user_id=175228
There are N! ways to write the toString() representation of
an ObjectName with N properties and only one ordered
representation, that given by ObjectName.getCanonicalName().
getCanonicalName() is used in the implementation of equals
which is why the given example works from the
obj.equals(obj2) perspective.
obj.toString().equals(obj2.toString()) has no guarentee of
equality while
obj.getCanonicalName().equals(obj2.getCanonicalName()) does.
Further, the jmx 1.2 javadocs for toString state:
<p>Returns a string representation of the object name. The
format of this string is not specified, but users can expect
that two ObjectNames return the same string if and only if they
are equal.
</p>
This does not imply that two ObjectNames which are equal
must return the same toString value.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=886544&group_id=22866
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development