summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2022-06-07 11:36:11 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2022-06-07 11:36:11 +0200
commit1bd087a7f515bcd944f8d8a1fbb26a0184bdccf6 (patch)
tree2839a0a46e226df5ffa1d2cd32c9b71d48ca513f
parent29dce2e7beacabc3beb2d4ca7362df42a71e5a7a (diff)
parenta96645a5f3e97b5c291ff51b8a4d1654052266b4 (diff)
downloadjgit-1bd087a7f515bcd944f8d8a1fbb26a0184bdccf6.tar.gz
jgit-1bd087a7f515bcd944f8d8a1fbb26a0184bdccf6.zip
Merge branch 'stable-6.0' into stable-6.1
* stable-6.0: Fix connection leak for smart http connections Change-Id: I8b7e643b87c0f788cdafb060a2c9e8b4ef6f7375
-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);
+ }
}
}