Bug 821058

Summary: Protect Set passed in MeasurementFacet.getValues()
Product: [Other] RHQ Project Reporter: Elias Ross <genman>
Component: Plugin ContainerAssignee: John Mazzitelli <mazz>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 4.2CC: hrupp
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-09-01 15:20:22 EDT Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Attachments:
Description Flags
patch to measurement subsystem in PC none

Description Elias Ross 2012-05-11 13:38:13 EDT
Description of problem:

I have a plugin that uses the subclass and parent class to obtain measurement values. I wrote the code in the following way:

    @Override
    public void getValues(MeasurementReport mr, Set<MeasurementScheduleRequest> msrs) {
        Map<String, Double> map = new HashMap<String, Double>();
        try {
            getMeasurements(map);
        } catch (Exception e) {
            log.warn("failed to digest additional content", e);
        }
        for (Iterator<MeasurementScheduleRequest> i = msrs.iterator(); i.hasNext(); ) {
            MeasurementScheduleRequest msr = i.next();
            Double d = digest.get(msr.getName());
            if (d != null) {
                mr.addData(new MeasurementDataNumeric(msr, d));
                i.remove(); // XXX
            }
        }
        super.getValues(mr, msrs);
    }

What this does, unfortunately, is unschedule the measurement request.

The "Set" passed into the method should either be read-only or a copy.

It would probably be better to be read-only, though.



Version-Release number of selected component (if applicable):

RHQ 4.2

How reproducible:

Always


Additional info:
Comment 1 Heiko W. Rupp 2012-06-21 05:33:23 EDT
Mazz, could you look into this? I think it makes a lot of sense
Comment 2 John Mazzitelli 2012-06-22 10:11:30 EDT
Created attachment 593763 [details]
patch to measurement subsystem in PC

attaching a patch for the PC's measurement classes that will now pass in a read-only set.

this isn't the finished patch. I will be looking at writing unit tests for this prior to committing to master. But the patch should be all the code that goes into the PC. any additional changes will be to test classes.
Comment 3 John Mazzitelli 2012-06-25 15:41:12 EDT
git commit to master 2af89d1

added a new unit test in our arquillian test suite.

there is nothing for QE to test - this is a code change.
Comment 4 Heiko W. Rupp 2013-09-01 15:20:22 EDT
Bulk closing of BZs that have no target version set, but which are ON_QA for more than a year and thus are in production for a long time.