java.jmx

Extend Destract protocol on nil to handle Null references gracefully

Details

  • Type: Defect Defect
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Patch:
    Code and Test
  • Approval:
    Accepted

Description

JMX Attributes can have null references. Currently a Exception is thrown because the "null-type" is not handled via objects->data:

user> (jmx/mbean "java.lang:type=GarbageCollector,name=PS MarkSweep")
{:LastGcInfo #<IllegalArgumentException java.lang.IllegalArgumentException: No implementation of method: :objects->data of protocol: #'clojure.java.jmx/Destract found for class: nil>, :CollectionCount 0, :CollectionTime 0, :MemoryPoolNames #<String[] [Ljava.lang.String;@57b8fe29>, :Name "PS MarkSweep", :Valid true, :ObjectName #<ObjectName java.lang:type=GarbageCollector,name=PS MarkSweep>}

After applying this patch:

user> (jmx/mbean "java.lang:type=GarbageCollector,name=PS MarkSweep")
{:LastGcInfo nil, :CollectionCount 0, :CollectionTime 0, :MemoryPoolNames #<String[] [Ljava.lang.String;@2225be1e>, :Name "PS MarkSweep", :Valid true, :ObjectName #<ObjectName java.lang:type=GarbageCollector,name=PS MarkSweep>}

Activity

Hide
Jürgen Hötzel added a comment -

I don't know of a standard MBean attribute which is reproducible Null. "LastGcInfo" of "java.lang:type=GarbageCollector,name=PS MarkSweep" is non-Null after a garbage collection.

I think its better to test the Destract protocol directly instead of using a "live" MBean in this case.

BTW. there was also a duplicate definition of the existing Destract tests in test-objects->data. Patches enclosed.

Show
Jürgen Hötzel added a comment - I don't know of a standard MBean attribute which is reproducible Null. "LastGcInfo" of "java.lang:type=GarbageCollector,name=PS MarkSweep" is non-Null after a garbage collection. I think its better to test the Destract protocol directly instead of using a "live" MBean in this case. BTW. there was also a duplicate definition of the existing Destract tests in test-objects->data. Patches enclosed.
Hide
Nick Bailey added a comment -

I don't suppose you know of a standard mbean that ships with most jvms we could use to write a test case for this?

Show
Nick Bailey added a comment - I don't suppose you know of a standard mbean that ships with most jvms we could use to write a test case for this?

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: