googleapis / googleapis/google-http-java-client

GZipEncoding should throw IOException from close

オープン
#868 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
type: cleanup
主要言語
Java
スター
1.4k
フォーク
473
PR マージ指標
30日以内にマージされた PR はありません

説明

The close method below swallows IOExceptions. That seems unnecessary and dangerous.

```
public class GZipEncoding implements HttpEncoding {

public String getName() {
return "gzip";
}

public void encode(StreamingContent content, OutputStream out) throws IOException {
// must not close the underlying output stream
OutputStream out2 =
new BufferedOutputStream(out) {
@Override
public void close() throws IOException {
// copy implementation of super.close(), except do not close the underlying output
// stream
try {
flush();
} catch (IOException ignored) {
// Nothing else we can do here
}
}
};
GZIPOutputStream zipper = new GZIPOutputStream(out2);
content.writeTo(zipper);
// cannot call just zipper.finish() because that would cause a severe memory leak
zipper.close();
}
}
```

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。