Merge branch 'stable-6.1' into stable-6.2

* stable-6.1:
  Fix connection leak for smart http connections

Change-Id: I4d38c62fa5416fd40b699de5b0ecfa03d498c21d
This commit is contained in:
Matthias Sohn 2022-06-07 11:36:46 +02:00
commit 4e2651e538
1 changed files with 24 additions and 12 deletions

View File

@ -1540,14 +1540,19 @@ class SmartHttpFetchConnection extends BasePackFetchConnection {
} }
@Override @Override
protected void doFetch(final ProgressMonitor monitor, protected void doFetch(ProgressMonitor monitor, Collection<Ref> want,
final Collection<Ref> want, final Set<ObjectId> have, Set<ObjectId> have, OutputStream outputStream)
final OutputStream outputStream) throws TransportException { throws TransportException {
try { svc = new MultiRequestService(SVC_UPLOAD_PACK,
svc = new MultiRequestService(SVC_UPLOAD_PACK, getProtocolVersion());
getProtocolVersion()); try (InputStream svcIn = svc.getInputStream();
init(svc.getInputStream(), svc.getOutputStream()); OutputStream svcOut = svc.getOutputStream()) {
init(svcIn, svcOut);
super.doFetch(monitor, want, have, outputStream); super.doFetch(monitor, want, have, outputStream);
} catch (TransportException e) {
throw e;
} catch (IOException e) {
throw new TransportException(e.getMessage(), e);
} finally { } finally {
svc = null; svc = null;
} }
@ -1571,13 +1576,20 @@ class SmartHttpPushConnection extends BasePackPushConnection {
} }
@Override @Override
protected void doPush(final ProgressMonitor monitor, protected void doPush(ProgressMonitor monitor,
final Map<String, RemoteRefUpdate> refUpdates, Map<String, RemoteRefUpdate> refUpdates,
OutputStream outputStream) throws TransportException { OutputStream outputStream) throws TransportException {
final Service svc = new MultiRequestService(SVC_RECEIVE_PACK, Service svc = new MultiRequestService(SVC_RECEIVE_PACK,
getProtocolVersion()); getProtocolVersion());
init(svc.getInputStream(), svc.getOutputStream()); try (InputStream svcIn = svc.getInputStream();
super.doPush(monitor, refUpdates, outputStream); 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);
}
} }
} }