Skip to content

MetarParseException processing remarks (quantity and height token) #3

@pasniak

Description

@pasniak

net.sf.jweather.metar.MetarParseException: Uncaught Exception during parse. Report: OMAL 290441Z 14005KT 1200 0600N R01/0900U R19/0400V0650U BCFG SCT002 13/13 Q1021 BECMG 5000 HZ Cause: java.lang.IndexOutOfBoundsException: Index: 14, Size: 14

Caused by: java.lang.IndexOutOfBoundsException: Index: 14, Size: 14
at java.util.ArrayList.rangeCheck(ArrayList.java:653)
at java.util.ArrayList.get(ArrayList.java:429)
at net.sf.jweather.metar.MetarParser.parseReport(MetarParser.java:1386)
... 31 more

tokens = {ArrayList@962} size = 14
0 = "OMAL"
1 = "290441Z"
2 = "14005KT"
3 = "1200"
4 = "0600N"
5 = "R01/0900U"
6 = "R19/0400V0650U"
7 = "BCFG"
8 = "SCT002"
9 = "13/13"
10 = "Q1021"
11 = "BECMG"
12 = "5000"
13 = "HZ"

possible fix :

                        // we have a quantity and height too
                        if (index<tokens.size() && (
                                ((String) tokens.get(index))
                                        .startsWith(MetarConstants.METAR_FEW)
                                || ((String) tokens.get(index))
                                        .startsWith(MetarConstants.METAR_SCATTERED)
                                || ((String) tokens.get(index))
                                        .startsWith(MetarConstants.METAR_BROKEN)
                                || ((String) tokens.get(index))
                                        .startsWith(MetarConstants.METAR_OVERCAST))
                                ) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions