Repository: ant-ivyde Updated Branches: refs/heads/master 122b5a2f7 -> 905b27e26
Use try with resources Project: http://git-wip-us.apache.org/repos/asf/ant-ivyde/repo Commit: http://git-wip-us.apache.org/repos/asf/ant-ivyde/commit/905b27e2 Tree: http://git-wip-us.apache.org/repos/asf/ant-ivyde/tree/905b27e2 Diff: http://git-wip-us.apache.org/repos/asf/ant-ivyde/diff/905b27e2 Branch: refs/heads/master Commit: 905b27e26e58d8c8708f9113d4dfc3c92e583e48 Parents: 122b5a2 Author: Gintas Grigelionis <gin...@apache.org> Authored: Fri Aug 10 14:05:16 2018 +0200 Committer: Gintas Grigelionis <gin...@apache.org> Committed: Fri Aug 10 14:07:03 2018 +0200 ---------------------------------------------------------------------- .../ivyde/internal/eclipse/CachedIvy.java | 32 +++++--------------- 1 file changed, 8 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/905b27e2/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/CachedIvy.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/CachedIvy.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/CachedIvy.java index 3932aca..7ce3646 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/CachedIvy.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/CachedIvy.java @@ -253,35 +253,19 @@ public abstract class CachedIvy { } else { IvyDEMessage.verbose(propFiles.size() + " property file(s) to load"); for (String file : propFiles) { - InputStream is; Path p = new Path(file); IvyDEMessage.debug("Loading property file " + p); - if (getProject() != null && !p.isAbsolute()) { - try { - is = new FileInputStream(getProject().getLocation().append(file).toFile()); - } catch (FileNotFoundException e) { - throw new IvyDEException("Property file not found", "The property file '" - + file + "' could not be found", e); - } - } else { - try { - is = new FileInputStream(file); - } catch (FileNotFoundException e) { - throw new IvyDEException("Property file not found", "The property file '" - + file + "' was not found", e); - } - } + String propFile = (getProject() != null && !p.isAbsolute()) + ? getProject().getLocation().append(file).toString() : file; Properties props = new Properties(); - try { + try (InputStream is = new FileInputStream(propFile)) { props.load(is); + } catch (FileNotFoundException e) { + throw new IvyDEException("Property file not found", "The property file '" + + propFile + "' was not found", e); } catch (IOException e) { - throw new IvyDEException("Not a property file", "The property file '" + file - + "' could not be loaded", e); - } - try { - is.close(); - } catch (IOException e) { - // don't care + throw new IvyDEException("Not a property file", "The property file '" + + propFile + "' could not be loaded", e); } for (String key : props.stringPropertyNames()) {