mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
Make sure the InputStream is always closed
Moving the code to create the OutputStream wrappers into the try-block ensures that the InputStream is closed in case something goes wrong.
This commit is contained in:
parent
6cd52c123c
commit
a7c9804995
@ -52,16 +52,17 @@ public class BinaryTempFileBody implements Body {
|
||||
}
|
||||
|
||||
public void writeTo(OutputStream out) throws IOException, MessagingException {
|
||||
boolean closeStream = false;
|
||||
InputStream in = getInputStream();
|
||||
if (MimeUtil.isBase64Encoding(mEncoding)) {
|
||||
out = new Base64OutputStream(out);
|
||||
closeStream = true;
|
||||
} else if (MimeUtil.isQuotedPrintableEncoded(mEncoding)){
|
||||
out = new QuotedPrintableOutputStream(out, false);
|
||||
closeStream = true;
|
||||
}
|
||||
try {
|
||||
boolean closeStream = false;
|
||||
if (MimeUtil.isBase64Encoding(mEncoding)) {
|
||||
out = new Base64OutputStream(out);
|
||||
closeStream = true;
|
||||
} else if (MimeUtil.isQuotedPrintableEncoded(mEncoding)){
|
||||
out = new QuotedPrintableOutputStream(out, false);
|
||||
closeStream = true;
|
||||
}
|
||||
|
||||
try {
|
||||
IOUtils.copy(in, out);
|
||||
} finally {
|
||||
|
@ -4028,16 +4028,17 @@ public class LocalStore extends Store implements Serializable {
|
||||
|
||||
@Override
|
||||
public void writeTo(OutputStream out) throws IOException, MessagingException {
|
||||
boolean closeStream = false;
|
||||
InputStream in = getInputStream();
|
||||
if (MimeUtil.isBase64Encoding(mEncoding)) {
|
||||
out = new Base64OutputStream(out);
|
||||
closeStream = true;
|
||||
} else if (MimeUtil.isQuotedPrintableEncoded(mEncoding)){
|
||||
out = new QuotedPrintableOutputStream(out, false);
|
||||
closeStream = true;
|
||||
}
|
||||
try {
|
||||
boolean closeStream = false;
|
||||
if (MimeUtil.isBase64Encoding(mEncoding)) {
|
||||
out = new Base64OutputStream(out);
|
||||
closeStream = true;
|
||||
} else if (MimeUtil.isQuotedPrintableEncoded(mEncoding)){
|
||||
out = new QuotedPrintableOutputStream(out, false);
|
||||
closeStream = true;
|
||||
}
|
||||
|
||||
try {
|
||||
IOUtils.copy(in, out);
|
||||
} finally {
|
||||
|
Loading…
Reference in New Issue
Block a user