From: <sc...@hy...> - 2010-01-13 19:25:35
|
Author: scottmf Date: 2010-01-13 11:25:26 -0800 (Wed, 13 Jan 2010) New Revision: 14173 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14173 Modified: trunk/src/org/hyperic/hq/bizapp/server/session/MetricSessionEJB.java Log: [HHQ-3667] removed a couple NPE potentials Modified: trunk/src/org/hyperic/hq/bizapp/server/session/MetricSessionEJB.java =================================================================== --- trunk/src/org/hyperic/hq/bizapp/server/session/MetricSessionEJB.java 2010-01-13 18:15:23 UTC (rev 14172) +++ trunk/src/org/hyperic/hq/bizapp/server/session/MetricSessionEJB.java 2010-01-13 19:25:26 UTC (rev 14173) @@ -426,8 +426,9 @@ if (r == null || r.isInAsyncDeleteState()) { continue; } - Measurement meas = (Measurement)midMap.get(r.getId()); - if (null == midMap || null == meas) { + Measurement meas; + if (null == midMap + || null == (meas = (Measurement)midMap.get(r.getId()))) { if (debug) watch.markTimeBegin("getAvailabilityMeasurement"); meas = mMan.getAvailabilityMeasurement(r); if (debug) watch.markTimeEnd("getAvailabilityMeasurement"); @@ -615,23 +616,20 @@ if (debug) watch.markTimeBegin("findResource size=" + size); final Resource res = rMan.findResource(id); if (debug) watch.markTimeEnd("findResource size=" + size); - - if (null != measCache) { - List list = (List) measCache.get(res.getId()); - - if (null != list) { - if (list.size() > 1) { - log.warn("resourceId " + res.getId() + - " has more than one availability measurement " + - " assigned to it"); - } else if (list.size() <= 0) { - continue; - } - final Measurement m = (Measurement)list.get(0); - rtn.put(res.getId(), m); - } else { - toGet.add(res); + List list; + if (null != measCache + && null != (list = (List)measCache.get(res.getId()))) { + if (list.size() > 1) { + log.warn("resourceId " + res.getId() + + " has more than one availability measurement " + + " assigned to it"); + } else if (list.size() <= 0) { + continue; } + final Measurement m = (Measurement)list.get(0); + rtn.put(res.getId(), m); + } else { + toGet.add(res); } } if (debug) watch.markTimeBegin("getAvailMeasurements"); |