Re: Can values be negative for CounterMonitors?
Eamonn McManus <[email protected]>
| Newsgroups | gmane.comp.java.mx4j.devel |
|---|---|
| Message-ID | <[email protected]> |
I think it is clear that the behaviour when the attribute observed by a CounterMonitor is negative is currently unspecified. Probably the best indication is in the Javadoc for the package javax.management.monitor (in J2SE 5), which says "the attributes are assumed to be non-negative." If that assumption is false, an implementation is pretty much free to do what it likes. This includes the current behaviours of the RI (treat a negative value the same as a non-negative one) and MX4J (send a THRESHOLD_ERROR notification). I agree with Luis-Miguel that the most logical behaviour would probably be to send an OBSERVED_ATTRIBUTE_TYPE_ERROR, just as we would if the value were not of integer type. *However* I think the risk of breaking existing code that relies on the current behaviour of JDK 5 outweighs the minimal advantage of specifying OBSERVED_ATTRIBUTE_TYPE_ERROR. Therefore I do not propose to change the spec so that it calls for this notification. At most, we could add some text that explicitly says that the behaviour is undefined for negative attributes. Jeremy, do you have a specific problem with the different behaviours of the RI and MX4J? Regards, Éamonn McManus JMX Spec Lead +33 476 188 352 Luis-Miguel Alventosa wrote: > > > Bordet, Simone wrote: > > Hi, > > > > > >>Page 150 of the spec says that the value of the observed > >>attribute "is always greater than or equal to zero." MX4J > >>enforces this restriction by sending a THRESHOLD_ERROR if the > >>value < 0; the RI appears not to, allowing negative attribute > >>values to be set. > >> > >>Am I misreading the intent of the specification here? Do we > >>need to remove this check? > > > > > > IMO this is a bug in the RI. > > Simon, > > I agree with you that this is a bug in the RI although it is > not clear to me by reading the Javadoc and the spec that this > is a THRESHOLD_ERROR. > > I'd like it to be an OBSERVED_ATTRIBUTE_TYPE_ERROR but I don't > know whether it fits into the following definition: > > jmx.monitor.error.type - Sent when the object instance of the > observed attribute value is null or > not of the appropriate type for the > given monitor. The observed object > name and observed attribute name are > provided in the notification. > > or the RUNTIME_ERROR one: > > jmx.monitor.error.runtime - All exceptions (except the cases > described above) that occur while > trying to get the value of the > observed attribute are caught by > the monitor and will be reported > in a notification of this type. > > Do you think a negative integer can be considered as a non > appropriate type for the positive integer the CounterMonitor > requires? > > Regards, > Luis > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Mx4j-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/mx4j-devel ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_ide95&alloc_id396&op=click