Issue #2741 Fixed nullpointers in Retrieval and BWM

Change-Id: I2530b194fa7f1b4fb2a6af4211e82b29b9b0c576

Former-commit-id: 6b263aa771 [formerly efbb7faced] [formerly c06fd8317c] [formerly 2e1d02fe21 [formerly c06fd8317c [formerly 3c47b3cb0ee18e485082e8a53d43b38722c5dce4]]]
Former-commit-id: 2e1d02fe21
Former-commit-id: b6e7eea399c4c32389427091c40541f8992bc3c5 [formerly 64991d004c]
Former-commit-id: 3bf1afdf70
This commit is contained in:
Dave Hladky 2014-01-26 16:48:09 -06:00
parent 0f64b9087f
commit e52c4df6e1
2 changed files with 24 additions and 15 deletions

View file

@ -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.
*
* </pre>
*
@ -244,14 +245,16 @@ public class InMemoryBandwidthBucketDao implements IBandwidthBucketDao {
final NavigableMap<Long, BandwidthBucket> 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<Long, BandwidthBucket> 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;
}

View file

@ -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;