aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2022-06-07 10:50:25 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2022-06-07 10:53:24 +0200
commitc7335f32e93b005fe681ed91873396a6d07886ad (patch)
tree6e5a7d9dd4bf6a2eba8052a9d5d327460c359796
parent78d4fb1ca00149a700f586357139f08efaa29ff6 (diff)
parent85011b8b07e244471d7b29ab2528183c1ba6556f (diff)
downloadjgit-c7335f32e93b005fe681ed91873396a6d07886ad.tar.gz
jgit-c7335f32e93b005fe681ed91873396a6d07886ad.zip
Merge branch 'stable-5.10' into stable-5.11
* stable-5.10: Fix connection leak for smart http connections Change-Id: I3885c6114caed897f762f5ce523d3b27288205b2
-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 2e5d18dc15..a5b377366f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
@@ -1529,14 +1529,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;
}
@@ -1560,13 +1565,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);
+ }
}
}