Fix regression in stream handling : do not close quoteOs, this would close the underlying stream

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@53 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2007-04-26 10:54:42 +00:00
parent 8ab4d39cc6
commit 8ba3b3ac8b
2 changed files with 4 additions and 11 deletions

View File

@ -928,11 +928,13 @@ public class ExchangeSession {
}
protected void writeAttachment(OutputStream os, MimeHeader mimeHeader, Attachment attachment) throws IOException {
OutputStream quotedOs = null;
try {
// quotedOs must not be closed : this would close the underlying outputstream
OutputStream quotedOs;
try {
// try another base64Encoder implementation
if ("base64".equalsIgnoreCase(mimeHeader.contentTransferEncoding)) {
//noinspection IOResourceOpenedButNotSafelyClosed
quotedOs = new BASE64EncoderStream(os);
} else {
quotedOs = (MimeUtility.encode(os, mimeHeader.contentTransferEncoding));
@ -989,7 +991,6 @@ public class ExchangeSession {
}
}
}
bis.close();
quotedOs.flush();
os.write('\r');
os.write('\n');
@ -997,14 +998,6 @@ public class ExchangeSession {
} catch (HttpException e) {
throw new IOException(e + " " + e.getMessage());
} finally {
if (quotedOs != null) {
try {
quotedOs.close();
} catch (IOException e) {
// ignore
}
}
}
}

View File

@ -14,7 +14,7 @@ public class TestExchangeSession {
ExchangeSession session = new ExchangeSession();
// test auth
try {
session.checkConfig();
ExchangeSession.checkConfig();
session.login(argv[1], argv[2]);
ExchangeSession.Folder folder = session.selectFolder(argv[3]);