Issue #2489 Fix SfcObs NPE.

Former-commit-id: ddf506ceac [formerly f9ee49fac5 [formerly 3013c7d2bbf38ab9c27491eb3cade83eaafc35aa]]
Former-commit-id: f9ee49fac5
Former-commit-id: 59d8afc639
This commit is contained in:
Ben Steffensmeier 2013-10-29 10:58:54 -05:00
parent 90a54524c6
commit 4f29903ddc
3 changed files with 27 additions and 11 deletions

View file

@ -37,8 +37,9 @@ import java.util.Map;
* SOFTWARE HISTORY * SOFTWARE HISTORY
* *
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------- -------- ----------- --------------------------
* 20070925 391 jkorman Initial Coding. * Sep 25, 2007 391 jkorman Initial Coding.
* Oct 29, 2013 2489 bsteffen Add NAVTEX_END_PART
* *
* </pre> * </pre>
* *
@ -70,6 +71,9 @@ public class SfcObsPart {
public static final SfcObsPart MAROB_PART = new SfcObsPart("MAROB",true); public static final SfcObsPart MAROB_PART = new SfcObsPart("MAROB",true);
public static final SfcObsPart NAVTEX_END_PART = new SfcObsPart("NNNN",
true);
private static final Map<String, SfcObsPart> OBS_TYPE_MAP = new HashMap<String, SfcObsPart>(); private static final Map<String, SfcObsPart> OBS_TYPE_MAP = new HashMap<String, SfcObsPart>();
static { static {
OBS_TYPE_MAP.put(AAXX_PART.partValue, AAXX_PART); OBS_TYPE_MAP.put(AAXX_PART.partValue, AAXX_PART);

View file

@ -32,8 +32,9 @@ import java.util.List;
* SOFTWARE HISTORY * SOFTWARE HISTORY
* *
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------- -------- ----------- --------------------------
* 20070925 391 jkorman Initial Coding. * Sep 25, 2007 391 jkorman Initial Coding.
* Oct 29, 2013 2489 bsteffen Add checks for NAVTEX_END_PART
* *
* </pre> * </pre>
* *
@ -136,6 +137,17 @@ public class SfcObsSubMessage {
// just throw it away. // just throw it away.
} else if (SfcObsPart.ME_PART.equals(part)) { } else if (SfcObsPart.ME_PART.equals(part)) {
break; break;
} else if (SfcObsPart.NAVTEX_END_PART.equals(part)) {
/*
* NNNN is an end of message token for some of the sbn
* data(NAVTEX generated data) and it is not a valid
* observation. If NNNN is the only part in the report then
* it will be ignored completely(dataWritten will be false).
* If there is other parts before or after NNNN then it will
* be included in the report.
*/
sb.append(" ");
sb.append(part.getPartValue());
} else { } else {
sb.append(" "); sb.append(" ");
sb.append(part.getPartValue()); sb.append(part.getPartValue());

View file

@ -34,11 +34,11 @@ import com.raytheon.uf.edex.wmo.message.WMOHeader;
* *
* <pre> * <pre>
* *
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------- -------- ----------- --------------------------
* 20071019 391 jkorman Initial coding. * Oct 19, 2007 391 jkorman Initial Coding.
* Oct 29, 2013 2489 bsteffen Add null check to matchElement.
*
* </pre> * </pre>
* *
* @author jkorman * @author jkorman
@ -166,7 +166,7 @@ public abstract class AbstractSfcObsDecoder implements ISfcObsDecoder {
*/ */
public static final boolean matchElement(String element, String pattern) { public static final boolean matchElement(String element, String pattern) {
boolean matches = false; boolean matches = false;
if (pattern != null) { if (pattern != null && element != null) {
Pattern p = Pattern.compile(pattern); Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(element); Matcher m = p.matcher(element);
matches = m.find(); matches = m.find();