Changeset 11168 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2016-10-26T14:02:13+02:00 (7 years ago)
Author:
simon04
Message:

fix #13828 - Fix IAE when adding WMS layer with invalid URL

The fix involves checking the URL when constructing WMSLayer instead when calling getTileSource

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/WMSLayer.java

    r11167 r11168  
    3030import org.openstreetmap.josm.gui.ExtendedDialog;
    3131import org.openstreetmap.josm.gui.layer.imagery.TileSourceDisplaySettings;
     32import org.openstreetmap.josm.tools.CheckParameterUtil;
    3233
    3334/**
     
    6162    public WMSLayer(ImageryInfo info) {
    6263        super(info);
     64        CheckParameterUtil.ensureThat(info.getImageryType() == ImageryType.WMS, "ImageryType is WMS");
     65        CheckParameterUtil.ensureParameterNotNull(info.getUrl(), "info.url");
     66        TemplatedWMSTileSource.checkUrl(info.getUrl());
    6367        this.supportedProjections = new TreeSet<>(info.getServerProjections());
    6468    }
     
    8286    @Override
    8387    protected AbstractWMSTileSource getTileSource() {
    84         if (info.getImageryType() == ImageryType.WMS && info.getUrl() != null) {
    85             TemplatedWMSTileSource.checkUrl(info.getUrl());
    86             AbstractWMSTileSource tileSource = new TemplatedWMSTileSource(info);
    87             info.setAttribution(tileSource);
    88             return tileSource;
    89         }
    90         return null;
     88        AbstractWMSTileSource tileSource = new TemplatedWMSTileSource(info);
     89        info.setAttribution(tileSource);
     90        return tileSource;
    9191    }
    9292
Note: See TracChangeset for help on using the changeset viewer.