Changeset 9407 in josm


Ignore:
Timestamp:
2016-01-11T03:31:44+01:00 (4 years ago)
Author:
Don-vip
Message:

findbugs - fix warning OBL_UNSATISFIED_OBLIGATION: "Version.init() may fail to clean up java.io.InputStream" by using try-with-resources

File:
1 edited

Legend:

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

    r9019 r9407  
    5858        try {
    5959            properties.load(revisionInfo);
    60             revisionInfo.close();
    6160        } catch (IOException e) {
    6261            Main.warn(tr("Error reading revision info from revision file: {0}", e.getMessage()));
     
    111110     */
    112111    public void init() {
    113         InputStream stream = Main.class.getResourceAsStream("/REVISION");
    114         if (stream == null) {
    115             Main.warn(tr("The revision file ''/REVISION'' is missing."));
    116             version = 0;
    117             releaseDescription = "";
    118             return;
    119         }
    120         initFromRevisionInfo(stream);
     112        try (InputStream stream = Main.class.getResourceAsStream("/REVISION")) {
     113            if (stream == null) {
     114                Main.warn(tr("The revision file ''/REVISION'' is missing."));
     115                version = 0;
     116                releaseDescription = "";
     117                return;
     118            }
     119            initFromRevisionInfo(stream);
     120        } catch (IOException e) {
     121            Main.warn(e);
     122        }
    121123    }
    122124
Note: See TracChangeset for help on using the changeset viewer.