summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2016-12-18 12:06:55 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2016-12-18 23:02:47 +0100
commita498a2865e6cd55de4c027d019584205a72c07c6 (patch)
tree6ffc32a203d6227af91b02886d094875ab6c96c1 /org.eclipse.jgit
parente78626f4140742bdffaca3689dbf1963d5dd30f3 (diff)
downloadjgit-a498a2865e6cd55de4c027d019584205a72c07c6.tar.gz
jgit-a498a2865e6cd55de4c027d019584205a72c07c6.zip
[infer] Fix resource leak in ManifestParser
Bug: 509385 Change-Id: Icfe58ac2e5344546448a55ad14ec082356be968c Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java22
1 files changed, 8 insertions, 14 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java
index 2370ae14c7..8a35d35fea 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/gitrepo/ManifestParser.java
@@ -215,10 +215,13 @@ public class ManifestParser extends DefaultHandler {
attributes.getValue("dest"))); //$NON-NLS-1$
} else if ("include".equals(qName)) { //$NON-NLS-1$
String name = attributes.getValue("name"); //$NON-NLS-1$
- InputStream is = null;
if (includedReader != null) {
- try {
- is = includedReader.readIncludeFile(name);
+ try (InputStream is = includedReader.readIncludeFile(name)) {
+ if (is == null) {
+ throw new SAXException(
+ RepoText.get().errorIncludeNotImplemented);
+ }
+ read(is);
} catch (Exception e) {
throw new SAXException(MessageFormat.format(
RepoText.get().errorIncludeFile, name), e);
@@ -226,22 +229,13 @@ public class ManifestParser extends DefaultHandler {
} else if (filename != null) {
int index = filename.lastIndexOf('/');
String path = filename.substring(0, index + 1) + name;
- try {
- is = new FileInputStream(path);
+ try (InputStream is = new FileInputStream(path)) {
+ read(is);
} catch (IOException e) {
throw new SAXException(MessageFormat.format(
RepoText.get().errorIncludeFile, path), e);
}
}
- if (is == null) {
- throw new SAXException(
- RepoText.get().errorIncludeNotImplemented);
- }
- try {
- read(is);
- } catch (IOException e) {
- throw new SAXException(e);
- }
}
}