소스 검색

Do not close ArchiveOutputStream on error

If we encounter an I/O error while writing an archive (for example due
to the reader of an HTTP stream closing the connection), the result is
an archive with unclosed entries, causing
TarArchiveOutputStream.finish() to throw IOException("This archives
contains unclosed entries"), hiding the IOException that caused the
early termination.

The unclosed entries are fine: the same exception that occured in the
first place will probably prevent closing the entries before finishing
this partial archive that should be discarded anyway.

It would be nicer to call TarArchiveOutputStream.finish and leave the
underlying OutputStream unclosed --- all callers close it already ---
but that would be a more invasive change so we hold off for now.

Change-Id: I328ced19aa8a1888e5353cdbb6106a85fd72d5d7
Signed-off-by: Jonathan Nieder <jrn@google.com>
tags/v3.2.0.201311130903-m3
Jonathan Nieder 10 년 전
부모
커밋
8a51c4453d
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2
    2
      org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java

+ 2
- 2
org.eclipse.jgit/src/org/eclipse/jgit/api/ArchiveCommand.java 파일 보기

@@ -111,7 +111,6 @@ public class ArchiveCommand extends GitCommand<OutputStream> {
* for (...) {
* format.putEntry(out, path, mode, repo.open(objectId));
* }
* } finally {
* out.close();
* }
*
@@ -287,8 +286,9 @@ public class ArchiveCommand extends GitCommand<OutputStream> {
walk.getObjectId(idBuf, 0);
fmt.putEntry(outa, name, mode, reader.open(idBuf));
}
} finally {
outa.close();
} finally {
out.close();
}
return out;
} catch (IOException e) {

Loading…
취소
저장