Browse Source

RepositoryCache#registerRepository: Refactor to use try-with-resource

Change-Id: Iaad45b66cc10ac267f6aed7999cc8dc8c07f92e6
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-5.0
David Pursehouse 7 years ago
parent
commit
11ddaff6af
  1. 6
      org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java

6
org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java

@ -288,9 +288,9 @@ public class RepositoryCache {
}
private void registerRepository(final Key location, final Repository db) {
Repository oldDb = cacheMap.put(location, db);
if (oldDb != null)
oldDb.close();
try (Repository oldDb = cacheMap.put(location, db)) {
// oldDb is auto-closed
}
}
private Repository unregisterRepository(final Key location) {

Loading…
Cancel
Save