summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2015-04-10 23:53:08 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2015-05-26 10:52:23 +0200
commit11a0dffd16e998959e3145de9c48dbdaf8f9757b (patch)
tree7df804c482f9875b2780962d32b531179e305a7c
parentd5a34551d595a348eb6234b9cf295a584a5cb1d6 (diff)
downloadjgit-11a0dffd16e998959e3145de9c48dbdaf8f9757b.tar.gz
jgit-11a0dffd16e998959e3145de9c48dbdaf8f9757b.zip
Silence resource leak warnings where caller is responsible to close
Change-Id: I63a74651689c10426d5f150ab2e027c6b63cab95 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java1
2 files changed, 5 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java
index eecbc224bc..45dd7ee1ac 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java
@@ -565,14 +565,16 @@ public class BaseRepositoryBuilder<B extends BaseRepositoryBuilder, R extends Re
* based on other options. If insufficient information is available, an
* exception is thrown to the caller.
*
- * @return a repository matching this configuration.
+ * @return a repository matching this configuration. The caller is
+ * responsible to close the repository instance when it is no longer
+ * needed.
* @throws IllegalArgumentException
* insufficient parameters were set.
* @throws IOException
* the repository could not be accessed to configure the rest of
* the builder's parameters.
*/
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({ "unchecked", "resource" })
public R build() throws IOException {
R repo = (R) new FileRepository(setup());
if (isMustExist() && !repo.getObjectDatabase().exists())
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java
index c7d957c4fb..0c58a0bea4 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java
@@ -159,6 +159,7 @@ public class RepositoryCache {
openLocks[i] = new Lock();
}
+ @SuppressWarnings("resource")
private Repository openRepository(final Key location,
final boolean mustExist) throws IOException {
Reference<Repository> ref = cacheMap.get(location);