From 89388d67f820b379ce2fa58539959f5f61a44fde Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Thu, 11 Oct 2018 14:42:28 +0200 Subject: Fix file handle leak in ObjectDownloadListener.onWritePossible 5c134f4d removed closing the input stream when we reached end of the stream. This caused file handle leaks. Bug: 540049 Change-Id: I48082b537077c7471fc160f59aa04deb99687d9b Signed-off-by: Matthias Sohn --- .../src/org/eclipse/jgit/lfs/server/fs/ObjectDownloadListener.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs') diff --git a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/ObjectDownloadListener.java b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/ObjectDownloadListener.java index 2dc9493f3f..a76f7ef0d8 100644 --- a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/ObjectDownloadListener.java +++ b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/fs/ObjectDownloadListener.java @@ -122,13 +122,18 @@ public class ObjectDownloadListener implements WriteListener { } else { buffer.flip(); } - } catch(Throwable t) { + } catch (Throwable t) { LOG.log(Level.SEVERE, t.getMessage(), t); buffer = null; } finally { if (buffer != null) { outChannel.write(buffer); } else { + try { + in.close(); + } catch (IOException e) { + LOG.log(Level.SEVERE, e.getMessage(), e); + } try { out.close(); } finally { -- cgit v1.2.3