Changeset 9480 in josm


Ignore:
Timestamp:
2016-01-16T03:00:56+01:00 (9 years ago)
Author:
Don-vip
Message:

fix #12376 - Multipolygon test hangs (patch by cmuelle8), regression from r9351

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/MultipolygonBuilder.java

    r9372 r9480  
    376376        @Override
    377377        protected List<PolygonLevel> compute() {
    378             if (to - from < directExecutionTaskSize) {
     378            if (to - from <= directExecutionTaskSize) {
    379379                return computeDirectly();
    380380            } else {
    381381                final Collection<ForkJoinTask<List<PolygonLevel>>> tasks = new ArrayList<>();
    382382                for (int fromIndex = from; fromIndex < to; fromIndex += directExecutionTaskSize) {
    383                     final List<PolygonLevel> output = new ArrayList<>();
    384                     tasks.add(new Worker(input, fromIndex, Math.min(fromIndex + directExecutionTaskSize, to), output, directExecutionTaskSize));
    385                 }
    386                 for (ForkJoinTask<List<PolygonLevel>> task : tasks) {
    387                     output.addAll(task.join());
     383                    tasks.add(new Worker(input, fromIndex, Math.min(fromIndex + directExecutionTaskSize, to), new ArrayList<PolygonLevel>(), directExecutionTaskSize));
     384                }
     385                for (ForkJoinTask<List<PolygonLevel>> task : ForkJoinTask.invokeAll(tasks)) {
     386                    List<PolygonLevel> res = task.join();
     387                    if (res == null) {
     388                        return null;
     389                    }
     390                    output.addAll(res);
    388391                }
    389392                return output;
  • trunk/test/unit/org/openstreetmap/josm/data/osm/MultipolygonBuilderTest.java

    r9476 r9480  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.osm;
     3
     4import static org.junit.Assert.assertNull;
    35
    46import java.io.FileInputStream;
     
    4244            DataSet ds = OsmReader.parseDataSet(Compression.BZIP2.getUncompressedInputStream(is), null);
    4345            for (Relation r : ds.getRelations()) {
    44                 new MultipolygonBuilder().makeFromWays(r.getMemberPrimitives(Way.class));
     46                assertNull(new MultipolygonBuilder().makeFromWays(r.getMemberPrimitives(Way.class)));
    4547            }
    4648        }
Note: See TracChangeset for help on using the changeset viewer.