diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2022-06-07 11:33:38 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2022-06-07 11:33:38 +0200 |
commit | 8bb17e518fb473beeeae363ceb23b706c6953527 (patch) | |
tree | e3c81a86962901b8ae3682f6313079d28eea396a | |
parent | 1e59cabc08ffddaae7129f0407f7ae17f01c5d90 (diff) | |
parent | c7335f32e93b005fe681ed91873396a6d07886ad (diff) | |
download | jgit-8bb17e518fb473beeeae363ceb23b706c6953527.tar.gz jgit-8bb17e518fb473beeeae363ceb23b706c6953527.zip |
Merge branch 'stable-5.11' into stable-5.12
* stable-5.11:
Fix connection leak for smart http connections
Change-Id: I6caabf4774ccf34706cef846c1087710f67e2ecd
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java index 0710d3fdfb..405373a0f9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java @@ -1540,14 +1540,19 @@ public class TransportHttp extends HttpTransport implements WalkTransport, } @Override - protected void doFetch(final ProgressMonitor monitor, - final Collection<Ref> want, final Set<ObjectId> have, - final OutputStream outputStream) throws TransportException { - try { - svc = new MultiRequestService(SVC_UPLOAD_PACK, - getProtocolVersion()); - init(svc.getInputStream(), svc.getOutputStream()); + protected void doFetch(ProgressMonitor monitor, Collection<Ref> want, + Set<ObjectId> have, OutputStream outputStream) + throws TransportException { + svc = new MultiRequestService(SVC_UPLOAD_PACK, + getProtocolVersion()); + try (InputStream svcIn = svc.getInputStream(); + OutputStream svcOut = svc.getOutputStream()) { + init(svcIn, svcOut); super.doFetch(monitor, want, have, outputStream); + } catch (TransportException e) { + throw e; + } catch (IOException e) { + throw new TransportException(e.getMessage(), e); } finally { svc = null; } @@ -1571,13 +1576,20 @@ public class TransportHttp extends HttpTransport implements WalkTransport, } @Override - protected void doPush(final ProgressMonitor monitor, - final Map<String, RemoteRefUpdate> refUpdates, + protected void doPush(ProgressMonitor monitor, + Map<String, RemoteRefUpdate> refUpdates, OutputStream outputStream) throws TransportException { - final Service svc = new MultiRequestService(SVC_RECEIVE_PACK, + Service svc = new MultiRequestService(SVC_RECEIVE_PACK, getProtocolVersion()); - init(svc.getInputStream(), svc.getOutputStream()); - super.doPush(monitor, refUpdates, outputStream); + try (InputStream svcIn = svc.getInputStream(); + OutputStream svcOut = svc.getOutputStream()) { + init(svcIn, svcOut); + super.doPush(monitor, refUpdates, outputStream); + } catch (TransportException e) { + throw e; + } catch (IOException e) { + throw new TransportException(e.getMessage(), e); + } } } |