Changeset 3512 in josm


Ignore:
Timestamp:
2010-09-04T14:10:43+02:00 (14 years ago)
Author:
bastiK
Message:

fixed #5373 - JOSM can't delete old and replace by new plugins (JOSM loaded icons from plugin jar file, but did not release file handles.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r3447 r3512  
    143143            if(archive != null)
    144144            {
     145                ZipFile zipFile = null;
    145146                try
    146147                {
    147                     ZipFile zipFile = new ZipFile(archive);
     148                    zipFile = new ZipFile(archive);
    148149                    ZipEntry entry = zipFile.getEntry(full_name);
    149150                    if(entry != null)
     
    152153                        int offs = 0;
    153154                        byte[] buf = new byte[size];
    154                         InputStream is = zipFile.getInputStream(entry);
    155                         while(size > 0)
    156                         {
    157                             int l = is.read(buf, offs, size);
    158                             offs += l;
    159                             size -= l;
     155                        InputStream is = null;
     156                        try {
     157                            is = zipFile.getInputStream(entry);
     158                            while(size > 0)
     159                            {
     160                                int l = is.read(buf, offs, size);
     161                                offs += l;
     162                                size -= l;
     163                            }
     164                            img = Toolkit.getDefaultToolkit().createImage(buf);
     165                        } finally {
     166                            if (is != null) {
     167                                is.close();
     168                            }
    160169                        }
    161                         img = Toolkit.getDefaultToolkit().createImage(buf);
    162170                    }
    163171                } catch (Exception e) {
    164172                    System.err.println(tr("Warning: failed to handle zip file ''{0}''. Exception was: {1}", archive.getName(), e.toString()));
     173                } finally {
     174                    if (zipFile != null) {
     175                        try {
     176                            zipFile.close();
     177                        } catch (IOException ex) {
     178                        }
     179                    }
    165180                }
    166181            }
Note: See TracChangeset for help on using the changeset viewer.