@Override protected void realRun() throws SAXException, IOException { try { uploadloop: while (true) { try { getProgressMonitor() .subTask( trn( "Uploading {0} object...", "Uploading {0} objects...", toUpload.getSize(), toUpload.getSize())); synchronized (this) { writer = new OsmServerWriter(); } writer.uploadOsm( strategy, toUpload.getPrimitives(), changeset, getProgressMonitor().createSubTaskMonitor(1, false)); // if we get here we've successfully uploaded the data. Exit the loop. // break; } catch (OsmTransferCancelledException e) { e.printStackTrace(); uploadCancelled = true; break uploadloop; } catch (OsmApiPrimitiveGoneException e) { // try to recover from 410 Gone // recoverFromGoneOnServer(e, getProgressMonitor()); } catch (ChangesetClosedException e) { processedPrimitives.addAll(writer.getProcessedPrimitives()); changeset.setOpen(false); switch (e.getSource()) { case UNSPECIFIED: throw e; case UPDATE_CHANGESET: // The changeset was closed when we tried to update it. Probably, our // local list of open changesets got out of sync with the server state. // The user will have to select another open changeset. // Rethrow exception - this will be handled later. // throw e; case UPLOAD_DATA: // Most likely the changeset is full. Try to recover and continue // with a new changeset, but let the user decide first (see // recoverFromChangesetFullException) // if (recoverFromChangesetFullException()) { continue; } lastException = e; break uploadloop; } } finally { if (writer != null) { processedPrimitives.addAll(writer.getProcessedPrimitives()); } synchronized (this) { writer = null; } } } // if required close the changeset // if (strategy.isCloseChangesetAfterUpload() && changeset != null && !changeset.isNew() && changeset.isOpen()) { OsmApi.getOsmApi() .closeChangeset(changeset, progressMonitor.createSubTaskMonitor(0, false)); } } catch (Exception e) { if (uploadCancelled) { System.out.println( tr( "Ignoring caught exception because upload is canceled. Exception is: {0}", e.toString())); } else { lastException = e; } } if (uploadCancelled && processedPrimitives.isEmpty()) return; cleanupAfterUpload(); }