Browse Source

Silence resource leak warnings where caller is responsible to close

Change-Id: I63a74651689c10426d5f150ab2e027c6b63cab95
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-4.1
Matthias Sohn 10 years ago
parent
commit
11a0dffd16
  1. 6
      org.eclipse.jgit/src/org/eclipse/jgit/lib/BaseRepositoryBuilder.java
  2. 1
      org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java

6
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())

1
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);

Loading…
Cancel
Save