summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);
+ }
}
}