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


Ignore:
Timestamp:
2009-07-25T11:12:35+02:00 (15 years ago)
Author:
Gubaer
Message:

cleanup in exception handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/OsmServerObjectReader.java

    r1811 r1827  
    3232    public DataSet parseOsm(ProgressMonitor progressMonitor) throws OsmTransferException {
    3333        progressMonitor.beginTask("", 1);
     34        InputStream in = null;
    3435        try {
    3536            progressMonitor.subTask(tr("Downloading OSM data..."));
     
    4243            }
    4344
    44             final InputStream in = getInputStream(sb.toString(), progressMonitor.createSubTaskMonitor(1, true));
     45            in = getInputStream(sb.toString(), progressMonitor.createSubTaskMonitor(1, true));
    4546            if (in == null)
    4647                return null;
    4748            final OsmReader osm = OsmReader.parseDataSetOsm(in, progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));
    4849            final DataSet data = osm.getDs();
    49 
    50             in.close();
    51             activeConnection = null;
    5250            return data;
    53         } catch (IOException e) {
    54             if (cancel)
    55                 return null;
    56             throw new OsmTransferException(e);
    57         } catch (SAXException e) {
    58             throw new OsmTransferException(e);
    5951        } catch(OsmTransferException e) {
     52            if (cancel) return null;
    6053            throw e;
    6154        } catch (Exception e) {
    62             if (cancel)
    63                 return null;
     55            if (cancel) return null;
    6456            throw new OsmTransferException(e);
    6557        } finally {
    6658            progressMonitor.finishTask();
     59            if (in!=null) {
     60                try {
     61                    in.close();
     62                } catch(Exception e) {}
     63            }
     64            activeConnection = null;
    6765        }
    6866    }
Note: See TracChangeset for help on using the changeset viewer.