Simplify based on feedback

This commit is contained in:
Philip Whitehouse 2016-11-24 23:11:03 +00:00
parent 3e6625dd24
commit 1497b5f781
6 changed files with 10 additions and 11 deletions

View file

@ -59,8 +59,6 @@ public class MessageExtractor {
} else {
throw new MessagingException("Provided invalid part: " + part);
}
} catch (UnsupportedContentTransferEncodingException e) {
Log.e(LOG_TAG, "Unable to getTextFromPart", e);
} catch (IOException e) {
Log.e(LOG_TAG, "Unable to getTextFromPart", e);
} catch (MessagingException e) {
@ -70,7 +68,7 @@ public class MessageExtractor {
}
private static String getTextFromTextPart(Part part, Body body, String mimeType, long textSizeLimit)
throws IOException, MessagingException, UnsupportedContentTransferEncodingException {
throws IOException, MessagingException {
/*
* We've got a text part, so let's see if it needs to be processed further.
*/

View file

@ -1018,7 +1018,7 @@ public class MimeUtility {
* The ultimate goal is to get to a point where all classes retain the original data and {@code RawDataBody} can be
* merged into {@link Body}.
*/
public static InputStream decodeBody(Body body) throws MessagingException, UnsupportedContentTransferEncodingException {
public static InputStream decodeBody(Body body) throws MessagingException {
InputStream inputStream;
if (body instanceof RawDataBody) {
RawDataBody rawDataBody = (RawDataBody) body;

View file

@ -1,6 +1,8 @@
package com.fsck.k9.mail.internet;
public class UnsupportedContentTransferEncodingException extends Exception {
import com.fsck.k9.mail.MessagingException;
public class UnsupportedContentTransferEncodingException extends MessagingException {
public UnsupportedContentTransferEncodingException(String encoding) {
super("Unsupported encoding: "+encoding);
}

View file

@ -78,7 +78,9 @@ public class MessageExtractorTest {
BinaryMemoryBody body = new BinaryMemoryBody("Sample text body".getBytes(), "unknown encoding");
part.setBody(body);
assertNull(MessageExtractor.getTextFromPart(part));
String result = MessageExtractor.getTextFromPart(part);
assertNull(result);
}
@Test

View file

@ -140,9 +140,7 @@ public class MimeMessageParseTest {
"\r\n" +
"dGhpcyBpcyBzb21lIG1vcmUgdGVzdCB0ZXh0Lg==\r\n"));
checkAddresses(msg.getFrom(), "adam@example.org");
checkAddresses(msg.getRecipients(RecipientType.TO), "eva@example.org");
streamToString(MimeUtility.decodeBody(msg.getBody()));
MimeUtility.decodeBody(msg.getBody());
}
@Test

View file

@ -32,7 +32,6 @@ import com.fsck.k9.mail.internet.MimeMessage;
import com.fsck.k9.mail.internet.MimeMultipart;
import com.fsck.k9.mail.internet.MimeUtility;
import com.fsck.k9.mail.internet.TextBody;
import com.fsck.k9.mail.internet.UnsupportedContentTransferEncodingException;
import com.fsck.k9.message.MessageBuilder.Callback;
import com.fsck.k9.view.RecipientSelectView.Recipient;
import org.apache.commons.io.IOUtils;
@ -508,7 +507,7 @@ public class PgpMessageBuilderTest {
InputStream inputStream = MimeUtility.decodeBody(signatureBodyPart.getBody());
IOUtils.copy(inputStream, bos);
Assert.assertEquals(reason, expected, new String(bos.toByteArray()));
} catch (IOException | MessagingException | UnsupportedContentTransferEncodingException e) {
} catch (IOException | MessagingException e) {
Assert.fail();
}
}