Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Keppler2019-02-05 08:47:10 +0000
committerMichael Keppler2019-02-05 08:47:10 +0000
commit5782320f342727e3fff68eae13169170f7656125 (patch)
tree6dac701f187e2835acb3a3100ddc76c7afbaecde
parent83d739c1308dcc5647503ad0153d3ca4b0386ac5 (diff)
downloadegit-5782320f342727e3fff68eae13169170f7656125.tar.gz
egit-5782320f342727e3fff68eae13169170f7656125.tar.xz
egit-5782320f342727e3fff68eae13169170f7656125.zip
Close resources
Found running deepcode.ai on the egit repository. Many of the other suggestions by the tool are not that good and just don't fit to our situation. Change-Id: Ib934a0bcfeda7285824c41fc5ede29dbc847ca9a Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/MockLogicalResourceMapping.java8
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/search/CommitSearchPage.java4
2 files changed, 6 insertions, 6 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/MockLogicalResourceMapping.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/MockLogicalResourceMapping.java
index 9a51d6397d..a8537e8633 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/MockLogicalResourceMapping.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/synchronize/MockLogicalResourceMapping.java
@@ -68,7 +68,7 @@ public class MockLogicalResourceMapping extends ResourceMapping {
public ResourceTraversal[] getTraversals(ResourceMappingContext context,
IProgressMonitor monitor) throws CoreException {
SubMonitor sm = SubMonitor.convert(monitor, 3);
- Set<IFile> result = new LinkedHashSet<IFile>();
+ Set<IFile> result = new LinkedHashSet<>();
result.add(file);
try {
List<IFile> dependencies = getDependencies(file, file.getParent());
@@ -103,9 +103,9 @@ public class MockLogicalResourceMapping extends ResourceMapping {
private List<IFile> getDependencies(IStorage storage, IContainer c)
throws CoreException, IOException {
List<IFile> result = new ArrayList<>();
- try (InputStream contents = storage.getContents();) {
- BufferedReader r = new BufferedReader(
- new InputStreamReader(contents, Charset.forName("UTF-8")));
+ try (InputStream contents = storage.getContents();
+ BufferedReader r = new BufferedReader(new InputStreamReader(
+ contents, Charset.forName("UTF-8")))) {
try {
while (true) {
String line = r.readLine();
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/search/CommitSearchPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/search/CommitSearchPage.java
index 35e6a6e189..5f41929e38 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/search/CommitSearchPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/search/CommitSearchPage.java
@@ -513,9 +513,9 @@ public class CommitSearchPage extends DialogPage implements ISearchPage {
if (text == null || text.length() == 0)
return ""; //$NON-NLS-1$
StringBuilder sbIn = new StringBuilder(text);
- BufferedReader reader = new BufferedReader(new StringReader(text));
int lengthOfFirstLine = 0;
- try {
+ try (BufferedReader reader = new BufferedReader(
+ new StringReader(text))) {
String l = reader.readLine();
if (l != null)
lengthOfFirstLine = l.length();

Back to the top