Source:
void sample(RrdDb dataBase, long timeInMs) throws IOException { Sample sample = dataBase.createSample(); for (String dataSource : dataSources.keySet()) { String fullName = dataSources.get(dataSource); String[] names = fullName.split("-"); String attrName = names[0]; String objectName = names[1]; try { Object attrValue = mbs.getAttribute(new ObjectName(objectName), attrName); if (attrValue instanceof CompositeDataSupport && compositeTypes.get(fullName) != null) { Object val = ((CompositeDataSupport) attrValue).get(compositeTypes.get(fullName)); if (val != null) { attrValue = val; } } sample.setValue(dataSource, Double.parseDouble(attrValue.toString())); if (logger.isTraceEnabled()) { logger.trace(timeInMs / 1000 + " sampling: " + dataSource + " / " + fullName + " " + Double.parseDouble(attrValue.toString())); } } catch (NumberFormatException ex) { if (logger.isTraceEnabled()) { logger.trace("Non numeric value for " + dataSource + " / " + fullName + ": " + ex.getMessage()); } } catch (InstanceNotFoundException | AttributeNotFoundException e) { if (logger.isTraceEnabled()) { logger.trace("Cannot read attribute " + attrName + " for object " + objectName + ": " + e.getMessage()); } } catch (UnsupportedOperationException e) { if (logger.isTraceEnabled()) { logger.warn("Cannot read attribute " + attrName + " for object " + objectName); } } catch (Exception e) { logger.warn("Error while reading attribute " + attrName + " for object " + objectName + ": ", e); } } try { sample.setTime(timeInMs / 1000); sample.update(); } catch (Exception e) { logger.error("Cannot update RRD database: " + e.getMessage()); } }

Target:
void sample(RrdDb dataBase, long timeInMs) throws IOException { Sample sample = dataBase.createSample(); for (String dataSource : dataSources.keySet()) { String fullName = dataSources.get(dataSource); String[] names = fullName.split("-"); String attrName = names[0]; String objectName = names[1]; try { Object attrValue = mbs.getAttribute(new ObjectName(objectName), attrName); if (attrValue instanceof CompositeDataSupport && compositeTypes.get(fullName) != null) { Object val = ((CompositeDataSupport) attrValue).get(compositeTypes.get(fullName)); if (val != null) { attrValue = val; } } sample.setValue(dataSource, Double.parseDouble(attrValue.toString())); if (logger.isTraceEnabled()) { logger.trace(timeInMs / 1000 + " sampling: " + dataSource + " / " + fullName + " " + Double.parseDouble(attrValue.toString())); } } catch (NumberFormatException ex) { if (logger.isTraceEnabled()) { logger.trace("Non numeric value for " + dataSource + " / " + fullName + ": " + ex.getMessage()); } } catch (InstanceNotFoundException | AttributeNotFoundException e) { if (logger.isTraceEnabled()) { logger.trace("Cannot read attribute " + attrName + " for object " + objectName + ": " + e.getMessage()); } } catch (UnsupportedOperationException e) { if (logger.isTraceEnabled()) { logger.warn("Error while reading attribute " + attrName + " for object " + objectName + ": ", e); } else if (logger.isDebugEnabled()) { logger.warn("Cannot read attribute " + attrName + " for object " + objectName); } } catch (Exception e) { logger.warn("Error while reading attribute " + attrName + " for object " + objectName + ": ", e); } } try { sample.setTime(timeInMs / 1000); sample.update(); } catch (Exception e) { logger.error("Cannot update RRD database: " + e.getMessage()); } }