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) { String exceptionAsString = StackTraceUtil.getStackTrace(ex).replaceAll("For input string: \".*\"", ""); exceptionAsString = dataSource + " / " + fullName + exceptionAsString; if (!exceptionsThrown.contains(exceptionAsString)) { exceptionsThrown.add(exceptionAsString); logger.warn("Non numeric value for " + dataSource + " / " + fullName + ": " + ex.getMessage()); } else { logger.trace("Non numeric value for " + dataSource + " / " + fullName + ": " + ex.getMessage()); } } catch (Exception e) { String exceptionAsString = StackTraceUtil.getStackTrace(e); if (!exceptionsThrown.contains(exceptionAsString)) { exceptionsThrown.add(exceptionAsString); logger.warn("Error while reading attribute " + attrName + " for object " + objectName + ": ", e); } else { logger.trace("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) { String exceptionAsString = StackTraceUtil.getStackTrace(ex).replaceAll("For input string: \".*\"", ""); exceptionAsString = fullName + " / " + exceptionAsString; if (!exceptionsThrown.contains(exceptionAsString)) { exceptionsThrown.add(exceptionAsString); logger.warn("Non numeric value for " + dataSource + " / " + fullName + ": " + ex.getMessage()); } else if (logger.isTraceEnabled()) { logger.trace("Non numeric value for " + dataSource + " / " + fullName + ": " + ex.getMessage()); } } catch (Exception e) { String exceptionAsString = StackTraceUtil.getStackTrace(e); if (!exceptionsThrown.contains(exceptionAsString)) { exceptionsThrown.add(exceptionAsString); logger.warn("Error while reading attribute " + attrName + " for object " + objectName + ": ", e); } else if (logger.isTraceEnabled()) { logger.trace("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()); } }