Bug 821058 - Protect Set passed in MeasurementFacet.getValues()
Summary: Protect Set passed in MeasurementFacet.getValues()
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: RHQ Project
Classification: Other
Component: Plugin Container
Version: 4.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: John Mazzitelli
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-05-11 17:38 UTC by Elias Ross
Modified: 2013-09-01 19:20 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-09-01 19:20:22 UTC
Embargoed:


Attachments (Terms of Use)
patch to measurement subsystem in PC (2.13 KB, patch)
2012-06-22 14:11 UTC, John Mazzitelli
no flags Details | Diff

Description Elias Ross 2012-05-11 17:38:13 UTC
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 09:33:23 UTC
Mazz, could you look into this? I think it makes a lot of sense

Comment 2 John Mazzitelli 2012-06-22 14:11:30 UTC
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 19:41:12 UTC
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 19:20:22 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.