Ticket #21011: 21011.patch

File 21011.patch, 3.3 KB (added by Bjoeni, 5 years ago)
  • src/org/openstreetmap/josm/data/gpx/GpxExtensionCollection.java

    ### Eclipse Workspace Patch 1.0
    #P josm-2
     
    99import java.util.stream.Collectors;
    1010import java.util.stream.Stream;
    1111
    12 import org.apache.commons.jcs3.access.exception.InvalidArgumentException;
    1312import org.openstreetmap.josm.io.GpxReader;
     13import org.openstreetmap.josm.tools.Logging;
    1414import org.xml.sax.Attributes;
    1515
    1616/**
     
    6060
    6161    /**
    6262     * Sets the value for the last child and pops it from the stack, so the next one will be added to its parent.
    63      * The qualified name is verified.
     63     * A warning is issued if the qualified name does not equal the currently opened child.
    6464     * @param qName the qualified name
    6565     * @param value the value
    6666     */
    6767    public void closeChild(String qName, String value) {
    68         if (childStack == null || childStack.isEmpty())
    69             throw new InvalidArgumentException("Can't close child " + qName + ", no element in stack.");
     68        if (childStack == null || childStack.isEmpty()) {
     69            Logging.warn("Can't close child \"" + qName + "\", no element in stack.");
     70            return;
     71                }
    7072
    7173        GpxExtension child = childStack.pop();
    72 
    7374        String childQN = child.getQualifiedName();
    7475
    7576        if (!childQN.equals(qName))
    76             throw new InvalidArgumentException("Can't close child " + qName + ", must close " + childQN + " first.");
     77            Logging.warn("Couldn't close child \"" + qName + "\", closed \"" + childQN + "\" instead.");
    7778
    7879        child.setValue(value);
    7980    }
  • src/org/openstreetmap/josm/io/GpxReader.java

     
    8383        private GpxExtensionCollection currentExtensionCollection;
    8484        private GpxExtensionCollection currentTrackExtensionCollection;
    8585        private Stack<State> states;
    86         private final Stack<String> elements = new Stack<>();
     86        private final Stack<String[]> elements = new Stack<>();
    8787
    8888        private StringBuilder accumulator = new StringBuilder();
    8989
     
    132132
    133133        @Override
    134134        public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
    135             elements.push(localName);
     135            elements.push(new String[] { namespaceURI, localName, qName });
    136136            switch(currentState) {
    137137            case INIT:
    138138                states.push(currentState);
     
    609609        }
    610610
    611611        void tryToFinish() throws SAXException {
    612             List<String> remainingElements = new ArrayList<>(elements);
     612            List<String[]> remainingElements = new ArrayList<>(elements);
    613613            for (int i = remainingElements.size() - 1; i >= 0; i--) {
    614                 endElement(null, remainingElements.get(i), remainingElements.get(i));
     614                String[] e = remainingElements.get(i);
     615                endElement(e[0], e[1], e[2]);
    615616            }
    616617            endDocument();
    617618        }