summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2022-06-07 11:34:25 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2022-06-07 11:34:25 +0200
commit5efd32e91da44bd05ff14dd7b35eccbecf54a095 (patch)
treedb653dbb28ce7d66a89c0bc17a3dfa8ac454de14
parentd67ac798f10254d038c49244e7f1e2323afdfdfc (diff)
parent8bb17e518fb473beeeae363ceb23b706c6953527 (diff)
downloadjgit-5efd32e91da44bd05ff14dd7b35eccbecf54a095.tar.gz
jgit-5efd32e91da44bd05ff14dd7b35eccbecf54a095.zip
Merge branch 'stable-5.12' into stable-5.13
* stable-5.12: Fix connection leak for smart http connections Change-Id: Id34f29c1b27a80c2b56c911cad7e3f64ef63af48
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java36
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);
+ }
}
}