diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/InMemoryBandwidthBucketDao.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/InMemoryBandwidthBucketDao.java index e4c4561f7c..4d77529315 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/InMemoryBandwidthBucketDao.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.bandwidth/src/com/raytheon/uf/edex/datadelivery/bandwidth/InMemoryBandwidthBucketDao.java @@ -58,6 +58,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil; * Sept 17, 2013 2383 bgonzale Switched back to start from ceiling and end from floor. * Constrain start and end keys by each other. * Dec 3, 2013 1736 dhladky Bandwidth bucket size attenuation. + * Jan 25, 2014 2741 dhladky Unsafe nullpointer being thrown. * * * @@ -244,14 +245,16 @@ public class InMemoryBandwidthBucketDao implements IBandwidthBucketDao { final NavigableMap buckets = allBuckets .get(network); Long firstKey = buckets.floorKey(key); - if (firstKey < keyConstraint) { - // then go back to key before this one - firstKey = buckets.ceilingKey(key); + if (firstKey != null) { + if (firstKey < keyConstraint) { + // then go back to key before this one + firstKey = buckets.ceilingKey(key); + } } + // safety check if (firstKey == null) { firstKey = buckets.firstKey(); } - return firstKey; } @@ -267,14 +270,16 @@ public class InMemoryBandwidthBucketDao implements IBandwidthBucketDao { final NavigableMap buckets = allBuckets .get(network); Long lastKey = buckets.ceilingKey(key); - if (lastKey > keyConstraint) { - // then go back to key before this one - lastKey = buckets.floorKey(key); + if (lastKey != null) { + if (lastKey > keyConstraint) { + // then go back to key before this one + lastKey = buckets.floorKey(key); + } } + // safety check if (lastKey == null) { - lastKey = buckets.lastKey(); + lastKey = buckets.lastKey(); } - return lastKey; } diff --git a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/util/RetrievalGeneratorUtilities.java b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/util/RetrievalGeneratorUtilities.java index e0e6e8c396..cf662845a6 100644 --- a/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/util/RetrievalGeneratorUtilities.java +++ b/edexOsgi/com.raytheon.uf.edex.datadelivery.retrieval/src/com/raytheon/uf/edex/datadelivery/retrieval/util/RetrievalGeneratorUtilities.java @@ -68,13 +68,17 @@ public class RetrievalGeneratorUtilities { public static boolean findDuplicateUri(String dataUri, String plugin) { boolean isDuplicate = false; - String sql = "select id from " + plugin + " where datauri = '" - + dataUri + "'"; + try { + String sql = "select id from " + plugin + " where datauri = '" + + dataUri + "'"; - CoreDao dao = new CoreDao(DaoConfig.forDatabase("metadata")); - Object[] results = dao.executeSQLQuery(sql); - if (results.length > 0) { - isDuplicate = true; + CoreDao dao = new CoreDao(DaoConfig.forDatabase("metadata")); + Object[] results = dao.executeSQLQuery(sql); + if (results.length > 0) { + isDuplicate = true; + } + } catch (Exception e) { + statusHandler.error("Couldn't determine duplicate status! ", e); } return isDuplicate;