On Dec 28, 2004, at 7:50 AM, Ceki G�lc� wrote: The sequenceNumber+timestamp combination makes it easy to implement
equals() method for LoggingEvent.
The implementation might be easy, but appears problematic. The default
implementation of equals and getHashCode would be preferred if all you
cared about was object identity.
Object identity is not enough. Chainsaw as well as other receivers may access a source of LoggingEvent multiple times. In that case, we need an efficient way to discard duplicate LoggingEvents.
It may be preferable to move the definition of "close enough for chainsaw" or "close enough for queries" out into the consuming classes. I'll have to dig into this later since I'm on the road and not really set up for this type of code analysis.
If log4j 1.2.8 logging events are deserialized, it looks like they may all have the same sequence number so chainsaw might want to additional checks if the timestamps are the same and the sequenceNumber is the default value.
By overriding equals, you also are required to override hashCode (which you do) which ideally distributes the hash values uniformly over the value space of int. By my reading, it looks like the hash code is an XOR of the high 32 bits of the timestamp (despite the comment) and the sequence number. If I'm reading it right, that looks like all logging events with a given sequenceNumber within a fairly large timeframe (4 million seconds, 11 days or so) would have the same hash code. Even it it is fixed to use the lower 32-bits, the hash codes still would be fairly tightly clustered. We could write a better hashCode, I'm just pointing out one of the side effects of choosing to override equals.
All in all, I think overriding equals just gives us headaches we could avoid by doing the appropriate comparison in the consuming classes.
p.s. LoggingEvent has commented out methods xgetMDCCopy and XXgetMDCKeySet. Are these going to be deleted or uncommented?
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
