]> source.dussan.org Git - jgit.git/commitdiff
Silence resource leak warnings where caller is responsible to close 04/45704/5
authorMatthias Sohn <matthias.sohn@sap.com>
Fri, 10 Apr 2015 21:53:08 +0000 (23:53 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 26 May 2015 08:52:23 +0000 (10:52 +0200)
Change-Id: I63a74651689c10426d5f150ab2e027c6b63cab95
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java

index eecbc224bc7d8f1a85af02f1d20c9e186906155e..45dd7ee1acca22a64e981685c9de984cca965ba8 100644 (file)
@@ -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())
index c7d957c4fb860b8ef53e3c2cdde310d844967b05..0c58a0bea43c5208961dd676bace7a233084fbe2 100644 (file)
@@ -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);