Changeset 6199 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2013-08-27T01:17:02+02:00 (11 years ago)
Author:
Don-vip
Message:

fix #9017 - NPE in AbstractUploadTask.handleUploadConflict()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/io/AbstractUploadTask.java

    r6046 r6199  
    2525import org.openstreetmap.josm.gui.ExceptionDialogUtil;
    2626import org.openstreetmap.josm.gui.HelpAwareOptionPane;
     27import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec;
    2728import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    28 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec;
    2929import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    3030import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     
    250250     */
    251251    protected void handleUploadConflict(OsmApiException e) {
    252         String pattern = "Version mismatch: Provided (\\d+), server had: (\\d+) of (\\S+) (\\d+)";
    253         Pattern p = Pattern.compile(pattern);
    254         Matcher m = p.matcher(e.getErrorHeader());
    255         if (m.matches()) {
    256             handleUploadConflictForKnownConflict(OsmPrimitiveType.from(m.group(3)), Long.parseLong(m.group(4)), m.group(2),m.group(1));
    257             return;
    258         }
    259         pattern ="The changeset (\\d+) was closed at (.*)";
    260         p = Pattern.compile(pattern);
    261         m = p.matcher(e.getErrorHeader());
    262         if (m.matches()) {
    263             handleUploadConflictForClosedChangeset(Long.parseLong(m.group(1)), DateUtils.fromString(m.group(2)));
    264             return;
    265         }
    266         System.out.println(tr("Warning: error header \"{0}\" did not match with an expected pattern", e.getErrorHeader()));
     252        final String errorHeader = e.getErrorHeader();
     253        if (errorHeader != null) {
     254            Pattern p = Pattern.compile("Version mismatch: Provided (\\d+), server had: (\\d+) of (\\S+) (\\d+)");
     255            Matcher m = p.matcher(errorHeader);
     256            if (m.matches()) {
     257                handleUploadConflictForKnownConflict(OsmPrimitiveType.from(m.group(3)), Long.parseLong(m.group(4)), m.group(2),m.group(1));
     258                return;
     259            }
     260            p = Pattern.compile("The changeset (\\d+) was closed at (.*)");
     261            m = p.matcher(errorHeader);
     262            if (m.matches()) {
     263                handleUploadConflictForClosedChangeset(Long.parseLong(m.group(1)), DateUtils.fromString(m.group(2)));
     264                return;
     265            }
     266        }
     267        System.out.println(tr("Warning: error header \"{0}\" did not match with an expected pattern", errorHeader));
    267268        handleUploadConflictForUnknownConflict();
    268269    }
Note: See TracChangeset for help on using the changeset viewer.