Changeset 11629 in josm for trunk


Ignore:
Timestamp:
2017-02-26T02:13:15+01:00 (8 years ago)
Author:
Don-vip
Message:

see #3346 - findbugs - IS2_INCONSISTENT_SYNC

File:
1 edited

Legend:

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

    r11627 r11629  
    6161 *
    6262 * Dataset is threadsafe - accessing Dataset simultaneously from different threads should never
    63  * lead to data corruption or ConccurentModificationException. However when for example one thread
     63 * lead to data corruption or ConcurrentModificationException. However when for example one thread
    6464 * removes primitive and other thread try to add another primitive referring to the removed primitive,
    6565 * DataIntegrityException will occur.
     
    966966
    967967    @Override
    968     public Collection<DataSource> getDataSources() {
     968    public synchronized Collection<DataSource> getDataSources() {
    969969        return Collections.unmodifiableCollection(dataSources);
    970970    }
     
    13831383        if (from != null) {
    13841384            new DataSetMerger(this, from).merge(progressMonitor);
    1385             if (!from.dataSources.isEmpty()) {
    1386                 if (dataSources.addAll(from.dataSources)) {
    1387                     cachedDataSourceArea = null;
    1388                     cachedDataSourceBounds = null;
     1385            synchronized (from) {
     1386                if (!from.dataSources.isEmpty()) {
     1387                    if (dataSources.addAll(from.dataSources)) {
     1388                        cachedDataSourceArea = null;
     1389                        cachedDataSourceBounds = null;
     1390                    }
     1391                    from.dataSources.clear();
     1392                    from.cachedDataSourceArea = null;
     1393                    from.cachedDataSourceBounds = null;
    13891394                }
    1390                 from.dataSources.clear();
    1391                 from.cachedDataSourceArea = null;
    1392                 from.cachedDataSourceBounds = null;
    13931395            }
    13941396        }
     
    14031405    }
    14041406
    1405     public ProjectionBounds getDataSourceBoundingBox() {
     1407    /**
     1408     * Returns the data sources bounding box.
     1409     * @return the data sources bounding box
     1410     */
     1411    public synchronized ProjectionBounds getDataSourceBoundingBox() {
    14061412        BoundingXYVisitor bbox = new BoundingXYVisitor();
    14071413        for (DataSource source : dataSources) {
     
    14131419        return null;
    14141420    }
    1415 
    14161421}
Note: See TracChangeset for help on using the changeset viewer.