diff options
author | David Pursehouse <david.pursehouse@gmail.com> | 2018-02-27 14:21:36 +0900 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2018-03-03 23:58:49 +0100 |
commit | a73f6c60093e8477fa06313034cb325add79e85c (patch) | |
tree | ceb2891fcab2dabf0a389bf2a2009f8f2ddacede /org.eclipse.jgit | |
parent | 63be96f48884dab8611b9ad8ccc0ad030a2056a4 (diff) | |
download | jgit-a73f6c60093e8477fa06313034cb325add79e85c.tar.gz jgit-a73f6c60093e8477fa06313034cb325add79e85c.zip |
DaemonService: Open Repository in try-with-resource
Change-Id: I8deec91d91e82c7cb186cfa9507eb443dd87aad3
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/DaemonService.java | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/DaemonService.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/DaemonService.java index e0ec7751b9..712eb22152 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/DaemonService.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/DaemonService.java @@ -150,23 +150,15 @@ public abstract class DaemonService { throws IOException, ServiceNotEnabledException, ServiceNotAuthorizedException { final String name = commandLine.substring(command.length() + 1); - Repository db; - try { - db = client.getDaemon().openRepository(client, name); + try (Repository db = client.getDaemon().openRepository(client, name)) { + if (isEnabledFor(db)) { + execute(client, db); + } } catch (ServiceMayNotContinueException e) { // An error when opening the repo means the client is expecting a ref // advertisement, so use that style of error. PacketLineOut pktOut = new PacketLineOut(client.getOutputStream()); pktOut.writeString("ERR " + e.getMessage() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ - db = null; - } - if (db == null) - return; - try { - if (isEnabledFor(db)) - execute(client, db); - } finally { - db.close(); } } |