Ticket #17291: 17291-v2.patch

File 17291-v2.patch, 2.7 KB (added by GerdP, 7 years ago)
  • src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java

     
    5959 */
    6060public class MultiFetchServerObjectReader extends OsmServerReader {
    6161    /**
    62      * the max. number of primitives retrieved in one step. Assuming IDs with 7 digits,
    63      * this leads to a max. request URL of ~ 1600 Bytes ((7 digits +  1 Separator) * 200),
     62     * the max. number of primitives retrieved in one step. Assuming IDs with 10 digits,
     63     * this leads to a max. request URL of ~ 1900 Bytes ((10 digits +  1 Separator) * 170),
    6464     * which should be safe according to the
    6565     * <a href="http://www.boutell.com/newfaq/misc/urllength.html">WWW FAQ</a>.
    6666     */
    67     private static final int MAX_IDS_PER_REQUEST = 200;
     67    private static final int MAX_IDS_PER_REQUEST = 170;
    6868
    6969    private final Set<Long> nodes;
    7070    private final Set<Long> ways;
     
    334334            progressMonitor.subTask(msg + "... " + progressMonitor.getTicks() + '/' + progressMonitor.getTicksCount());
    335335            try {
    336336                FetchResult result = ecs.take().get();
     337                if (result.rc404 != null) {
     338                    List<Long> toSplit = new ArrayList<>(result.rc404);
     339                    int n = toSplit.size() / 2;
     340                    jobs.add(ecs.submit(new Fetcher(type, new HashSet<>(toSplit.subList(0, n)), progressMonitor)));
     341                    jobs.add(ecs.submit(new Fetcher(type, new HashSet<>(toSplit.subList(n, toSplit.size())), progressMonitor)));
     342                }
    337343                if (result.missingPrimitives != null) {
    338344                    missingPrimitives.addAll(result.missingPrimitives);
    339345                }
     
    427433         */
    428434        public final Set<PrimitiveId> missingPrimitives;
    429435
     436        private Set<Long> rc404;
     437
    430438        /**
    431439         * Constructs a {@code FetchResult}
    432440         * @param dataSet The resulting data set
     
    486494                return multiGetIdPackage(type, pkg, progressMonitor);
    487495            } catch (OsmApiException e) {
    488496                if (e.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
     497                    if (pkg.size() > 4) {
     498                        FetchResult res = new FetchResult(null, null);
     499                        res.rc404 = pkg;
     500                        return res;
     501                    }
    489502                    Logging.info(tr("Server replied with response code 404, retrying with an individual request for each object."));
    490503                    return singleGetIdPackage(type, pkg, progressMonitor);
    491504                } else {