Ticket #17291: 17291-v2.patch
| File 17291-v2.patch, 2.7 KB (added by , 7 years ago) |
|---|
-
src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java
59 59 */ 60 60 public class MultiFetchServerObjectReader extends OsmServerReader { 61 61 /** 62 * the max. number of primitives retrieved in one step. Assuming IDs with 7digits,63 * this leads to a max. request URL of ~ 1 600 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), 64 64 * which should be safe according to the 65 65 * <a href="http://www.boutell.com/newfaq/misc/urllength.html">WWW FAQ</a>. 66 66 */ 67 private static final int MAX_IDS_PER_REQUEST = 200;67 private static final int MAX_IDS_PER_REQUEST = 170; 68 68 69 69 private final Set<Long> nodes; 70 70 private final Set<Long> ways; … … 334 334 progressMonitor.subTask(msg + "... " + progressMonitor.getTicks() + '/' + progressMonitor.getTicksCount()); 335 335 try { 336 336 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 } 337 343 if (result.missingPrimitives != null) { 338 344 missingPrimitives.addAll(result.missingPrimitives); 339 345 } … … 427 433 */ 428 434 public final Set<PrimitiveId> missingPrimitives; 429 435 436 private Set<Long> rc404; 437 430 438 /** 431 439 * Constructs a {@code FetchResult} 432 440 * @param dataSet The resulting data set … … 486 494 return multiGetIdPackage(type, pkg, progressMonitor); 487 495 } catch (OsmApiException e) { 488 496 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 } 489 502 Logging.info(tr("Server replied with response code 404, retrying with an individual request for each object.")); 490 503 return singleGetIdPackage(type, pkg, progressMonitor); 491 504 } else {
