Issue #2359 prevent obnoxious ncep decoder null pointer exceptions

Change-Id: I731614a8a6c9ec38bb6c1b29c4d9f6ca5a7c03d7

Former-commit-id: 514d0cfecd3eb8c81a6d2120406225856d964c9e
This commit is contained in:
Nate Jensen 2014-01-07 12:38:49 -06:00
parent f0169367be
commit 2c0e3f05ca
3 changed files with 16 additions and 10 deletions

View file

@ -11,6 +11,7 @@
* and add xml for VORs and
* Intlsig gempak tables.
* 30 Sep 2009 3102 jkorman Changed printlns to logging statements.
* 07 Jan 2014 njensen Better error messages
*
* </pre>
*
@ -148,11 +149,11 @@ public class LatLonLocTbl {
point = new LatLonPoint(vor.getLatitude(), vor.getLongitude(),
LatLonPoint.INDEGREES);
} else {
logger.debug(" - DID NOT find station ID in vors.xml");
logger.warn(" - DID NOT find station ID " + navaid + " in vors.xml");
}
// If there's an offset direction/bearing, process it
if (location.length() > 3) {
if (location.length() > 3 && point != null) {
String u = location.substring(0, location.length() - 3);
Pattern p = Pattern.compile("^([0-9]+)\\s*([A-Z]+)");
@ -176,7 +177,7 @@ public class LatLonLocTbl {
return point;
} catch (Exception e) {
logger.error("[Error decoding location in LatLonLocTbl: "
+ location + "]");
+ location + "]", e);
return null;
}
}

View file

@ -13,6 +13,7 @@
* 09/2009 87/114 L. Lin Add latitude/longitude to location table
* 07/2011 87/114 F. J. Yen Fix the day of the end time when it is
* not the same as the day of the start time.
* Jan 07, 2014 njensen Handle if one or more locations not found in LatLonLocTbl
* </pre>
*
* This code has been developed by the SIB for use in the AWIPS2 system.
@ -631,16 +632,19 @@ public class ConvSigmetParser {
// Get a latLonPoint for this station ID from "vors"
// location table
point = LatLonLocTbl.getLatLonPoint(Location, "vors");
currentLocation.setLatitude(point
if(point != null) {
currentLocation.setLatitude(point
.getLatitude(LatLonPoint.INDEGREES));
currentLocation.setLongitude(point
currentLocation.setLongitude(point
.getLongitude(LatLonPoint.INDEGREES));
currentLocation.setIndex(idxLocation + 1);
idxLocation++;
currentLocation.setIndex(idxLocation + 1);
idxLocation++;
sectionTable.addConvSigmetLocation(currentLocation);
sectionTable.addConvSigmetLocation(currentLocation);
}
}
hasLocationLine = (idxLocation > 0);
} else {
hasLocationLine = false;
}

View file

@ -18,6 +18,7 @@
* 05/2010 14 T. Lee Migration to TO11DR11
* 06/2010 14 T. Lee Added traceId output
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
* Jan 07, 2013 njensen Null check on traceId
* </pre>
*
* @author T.Lee
@ -61,7 +62,7 @@ public class FfgDecoder extends AbstractDecoder {
if (headers != null) {
traceId = (String) headers.get("traceId");
if (traceId.compareTo(lastTraceId) != 0) {
if (traceId != null && traceId.compareTo(lastTraceId) != 0) {
System.out
.println(" Start decode FFG file: " + traceId + " \n");
lastTraceId = traceId;
@ -148,4 +149,4 @@ public class FfgDecoder extends AbstractDecoder {
}
return new PluginDataObject[] { record };
}
}
}