From c79ea226a5cc7fb02a280244577561094a5243d5 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Wed, 1 Dec 2010 03:02:13 +0000 Subject: [PATCH] Remove "throws" declarations that didn't actually get thrown. Remove a couple of try blocks that only caught throws we didn't throw. IntelliJ optimization. --- src/com/fsck/k9/K9.java | 2 +- src/com/fsck/k9/activity/MessageView.java | 3 +- .../k9/controller/MessagingController.java | 13 ++------- src/com/fsck/k9/mail/Folder.java | 4 +-- src/com/fsck/k9/mail/Message.java | 8 +++--- src/com/fsck/k9/mail/Multipart.java | 27 ++++++------------ src/com/fsck/k9/mail/Part.java | 4 +-- src/com/fsck/k9/mail/Store.java | 2 +- src/com/fsck/k9/mail/Transport.java | 2 +- .../k9/mail/internet/BinaryTempFileBody.java | 3 +- .../fsck/k9/mail/internet/MimeBodyPart.java | 9 ++---- src/com/fsck/k9/mail/internet/MimeHeader.java | 3 +- .../fsck/k9/mail/internet/MimeMessage.java | 28 ++++++------------- .../fsck/k9/mail/internet/MimeMultipart.java | 12 +++----- src/com/fsck/k9/mail/store/ImapStore.java | 18 ++++-------- src/com/fsck/k9/mail/store/LocalStore.java | 18 ++++-------- src/com/fsck/k9/mail/store/Pop3Store.java | 15 ++++------ .../fsck/k9/mail/store/StorageManager.java | 3 +- src/com/fsck/k9/mail/store/WebDavStore.java | 24 +++++----------- src/com/fsck/k9/preferences/Editor.java | 3 +- src/com/fsck/k9/provider/MessageProvider.java | 3 +- 21 files changed, 68 insertions(+), 136 deletions(-) diff --git a/src/com/fsck/k9/K9.java b/src/com/fsck/k9/K9.java index 1ee8bcc09..1a029e46f 100644 --- a/src/com/fsck/k9/K9.java +++ b/src/com/fsck/k9/K9.java @@ -53,7 +53,7 @@ public class K9 extends Application * The application instance. Never null. * @throws Exception */ - void initializeComponent(K9 application) throws Exception; + void initializeComponent(K9 application); } public static Application app = null; diff --git a/src/com/fsck/k9/activity/MessageView.java b/src/com/fsck/k9/activity/MessageView.java index 128456971..29fc024b1 100644 --- a/src/com/fsck/k9/activity/MessageView.java +++ b/src/com/fsck/k9/activity/MessageView.java @@ -2090,8 +2090,7 @@ public class MessageView extends K9Activity implements OnClickListener } } - private Bitmap getPreviewIcon(Attachment attachment) throws MessagingException - { + private Bitmap getPreviewIcon(Attachment attachment) { try { return BitmapFactory.decodeStream( diff --git a/src/com/fsck/k9/controller/MessagingController.java b/src/com/fsck/k9/controller/MessagingController.java index d7581b28b..098b38964 100644 --- a/src/com/fsck/k9/controller/MessagingController.java +++ b/src/com/fsck/k9/controller/MessagingController.java @@ -3206,8 +3206,7 @@ public class MessagingController implements Runnable * Check if the attachment has already been downloaded. If it has there's no reason to * download it, so we just tell the listener that it's ready to go. */ - try - { + if (part.getBody() != null) { for (MessagingListener l : getListeners()) @@ -3230,14 +3229,8 @@ public class MessagingController implements Runnable } return; } - } - catch (MessagingException me) - { - /* - * If the header isn't there the attachment isn't downloaded yet, so just continue - * on. - */ - } + + for (MessagingListener l : getListeners()) { diff --git a/src/com/fsck/k9/mail/Folder.java b/src/com/fsck/k9/mail/Folder.java index 644cdb55e..f61ac21f9 100644 --- a/src/com/fsck/k9/mail/Folder.java +++ b/src/com/fsck/k9/mail/Folder.java @@ -61,7 +61,7 @@ public abstract class Folder * was requested with. * @return */ - public abstract OpenMode getMode() throws MessagingException; + public abstract OpenMode getMode(); public abstract boolean create(FolderType type) throws MessagingException; @@ -151,7 +151,7 @@ public abstract class Folder public abstract String getName(); - public abstract Flag[] getPermanentFlags() throws MessagingException; + public abstract Flag[] getPermanentFlags(); /** * diff --git a/src/com/fsck/k9/mail/Message.java b/src/com/fsck/k9/mail/Message.java index cfb6e7dfb..9d3838f5f 100644 --- a/src/com/fsck/k9/mail/Message.java +++ b/src/com/fsck/k9/mail/Message.java @@ -84,7 +84,7 @@ public abstract class Message implements Part, Body return mFolder; } - public abstract String getSubject() throws MessagingException; + public abstract String getSubject(); public abstract void setSubject(String subject) throws MessagingException; @@ -115,11 +115,11 @@ public abstract class Message implements Part, Body }); } - public abstract Address[] getFrom() throws MessagingException; + public abstract Address[] getFrom(); public abstract void setFrom(Address from) throws MessagingException; - public abstract Address[] getReplyTo() throws MessagingException; + public abstract Address[] getReplyTo(); public abstract void setReplyTo(Address[] from) throws MessagingException; @@ -131,7 +131,7 @@ public abstract class Message implements Part, Body public abstract void setReferences(String references) throws MessagingException; - public abstract Body getBody() throws MessagingException; + public abstract Body getBody(); public abstract String getContentType() throws MessagingException; diff --git a/src/com/fsck/k9/mail/Multipart.java b/src/com/fsck/k9/mail/Multipart.java index e12dd69c0..93bb79586 100644 --- a/src/com/fsck/k9/mail/Multipart.java +++ b/src/com/fsck/k9/mail/Multipart.java @@ -14,48 +14,39 @@ public abstract class Multipart implements Body protected String mContentType; - public void addBodyPart(BodyPart part) throws MessagingException - { + public void addBodyPart(BodyPart part) { mParts.add(part); } - public void addBodyPart(BodyPart part, int index) throws MessagingException - { + public void addBodyPart(BodyPart part, int index) { mParts.add(index, part); } - public BodyPart getBodyPart(int index) throws MessagingException - { + public BodyPart getBodyPart(int index) { return mParts.get(index); } - public String getContentType() throws MessagingException - { + public String getContentType() { return mContentType; } - public int getCount() throws MessagingException - { + public int getCount() { return mParts.size(); } - public boolean removeBodyPart(BodyPart part) throws MessagingException - { + public boolean removeBodyPart(BodyPart part) { return mParts.remove(part); } - public void removeBodyPart(int index) throws MessagingException - { + public void removeBodyPart(int index) { mParts.remove(index); } - public Part getParent() throws MessagingException - { + public Part getParent() { return mParent; } - public void setParent(Part parent) throws MessagingException - { + public void setParent(Part parent) { this.mParent = parent; } diff --git a/src/com/fsck/k9/mail/Part.java b/src/com/fsck/k9/mail/Part.java index 985d28bf5..5141e823c 100644 --- a/src/com/fsck/k9/mail/Part.java +++ b/src/com/fsck/k9/mail/Part.java @@ -12,7 +12,7 @@ public interface Part public void setHeader(String name, String value) throws MessagingException; - public Body getBody() throws MessagingException; + public Body getBody(); public String getContentType() throws MessagingException; @@ -22,7 +22,7 @@ public interface Part public String[] getHeader(String name) throws MessagingException; - public int getSize() throws MessagingException; + public int getSize(); public boolean isMimeType(String mimeType) throws MessagingException; diff --git a/src/com/fsck/k9/mail/Store.java b/src/com/fsck/k9/mail/Store.java index 59b13203f..f59f6ae9e 100644 --- a/src/com/fsck/k9/mail/Store.java +++ b/src/com/fsck/k9/mail/Store.java @@ -101,7 +101,7 @@ public abstract class Store return (LocalStore) store; } - public abstract Folder getFolder(String name) throws MessagingException; + public abstract Folder getFolder(String name); public abstract List getPersonalNamespaces(boolean forceListAll) throws MessagingException; diff --git a/src/com/fsck/k9/mail/Transport.java b/src/com/fsck/k9/mail/Transport.java index efc43ca9e..35d5c3380 100644 --- a/src/com/fsck/k9/mail/Transport.java +++ b/src/com/fsck/k9/mail/Transport.java @@ -33,5 +33,5 @@ public abstract class Transport public abstract void sendMessage(Message message) throws MessagingException; - public abstract void close() throws MessagingException; + public abstract void close(); } diff --git a/src/com/fsck/k9/mail/internet/BinaryTempFileBody.java b/src/com/fsck/k9/mail/internet/BinaryTempFileBody.java index cbef03092..9026cf5b8 100644 --- a/src/com/fsck/k9/mail/internet/BinaryTempFileBody.java +++ b/src/com/fsck/k9/mail/internet/BinaryTempFileBody.java @@ -24,8 +24,7 @@ public class BinaryTempFileBody implements Body mTempDirectory = tempDirectory; } - public BinaryTempFileBody() throws IOException - { + public BinaryTempFileBody() { if (mTempDirectory == null) { throw new diff --git a/src/com/fsck/k9/mail/internet/MimeBodyPart.java b/src/com/fsck/k9/mail/internet/MimeBodyPart.java index 8acd0bfec..9b85ac6f4 100644 --- a/src/com/fsck/k9/mail/internet/MimeBodyPart.java +++ b/src/com/fsck/k9/mail/internet/MimeBodyPart.java @@ -39,8 +39,7 @@ public class MimeBodyPart extends BodyPart setBody(body); } - protected String getFirstHeader(String name) throws MessagingException - { + protected String getFirstHeader(String name) { return mHeader.getFirstHeader(name); } @@ -64,8 +63,7 @@ public class MimeBodyPart extends BodyPart mHeader.removeHeader(name); } - public Body getBody() throws MessagingException - { + public Body getBody() { return mBody; } @@ -149,8 +147,7 @@ public class MimeBodyPart extends BodyPart return getMimeType().equals(mimeType); } - public int getSize() throws MessagingException - { + public int getSize() { return mSize; } diff --git a/src/com/fsck/k9/mail/internet/MimeHeader.java b/src/com/fsck/k9/mail/internet/MimeHeader.java index 1b260cf9f..614652f2b 100644 --- a/src/com/fsck/k9/mail/internet/MimeHeader.java +++ b/src/com/fsck/k9/mail/internet/MimeHeader.java @@ -111,8 +111,7 @@ public class MimeHeader mFields.removeAll(removeFields); } - public void writeTo(OutputStream out) throws IOException, MessagingException - { + public void writeTo(OutputStream out) throws IOException { BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out), 1024); for (Field field : mFields) { diff --git a/src/com/fsck/k9/mail/internet/MimeMessage.java b/src/com/fsck/k9/mail/internet/MimeMessage.java index 1072b9b7a..da6f31117 100644 --- a/src/com/fsck/k9/mail/internet/MimeMessage.java +++ b/src/com/fsck/k9/mail/internet/MimeMessage.java @@ -121,8 +121,7 @@ public class MimeMessage extends Message addSentDate(sentDate); } - public void setInternalSentDate(Date sentDate) throws MessagingException - { + public void setInternalSentDate(Date sentDate) { this.mSentDate = sentDate; } @@ -161,8 +160,7 @@ public class MimeMessage extends Message return MimeUtility.getHeaderParameter(getContentType(), null); } - public int getSize() throws MessagingException - { + public int getSize() { return mSize; } @@ -255,8 +253,7 @@ public class MimeMessage extends Message * Returns the unfolded, decoded value of the Subject header. */ @Override - public String getSubject() throws MessagingException - { + public String getSubject() { return MimeUtility.unfoldAndDecode(getFirstHeader("Subject")); } @@ -267,8 +264,7 @@ public class MimeMessage extends Message } @Override - public Address[] getFrom() throws MessagingException - { + public Address[] getFrom() { if (mFrom == null) { String list = MimeUtility.unfold(getFirstHeader("From")); @@ -299,8 +295,7 @@ public class MimeMessage extends Message } @Override - public Address[] getReplyTo() throws MessagingException - { + public Address[] getReplyTo() { if (mReplyTo == null) { mReplyTo = Address.parse(MimeUtility.unfold(getFirstHeader("Reply-to"))); @@ -410,8 +405,7 @@ public class MimeMessage extends Message } @Override - public Body getBody() throws MessagingException - { + public Body getBody() { return mBody; } @@ -649,14 +643,8 @@ public class MimeMessage extends Message { sb.append((char)b); } - try - { - ((MimeMultipart)stack.peek()).setPreamble(sb.toString()); - } - catch (MessagingException me) - { - throw new Error(me); - } + ((MimeMultipart)stack.peek()).setPreamble(sb.toString()); + } public void raw(InputStream is) throws IOException diff --git a/src/com/fsck/k9/mail/internet/MimeMultipart.java b/src/com/fsck/k9/mail/internet/MimeMultipart.java index 1363f5664..169cbf721 100644 --- a/src/com/fsck/k9/mail/internet/MimeMultipart.java +++ b/src/com/fsck/k9/mail/internet/MimeMultipart.java @@ -54,24 +54,20 @@ public class MimeMultipart extends Multipart return sb.toString().toUpperCase(); } - public String getPreamble() throws MessagingException - { + public String getPreamble() { return mPreamble; } - public void setPreamble(String preamble) throws MessagingException - { + public void setPreamble(String preamble) { this.mPreamble = preamble; } @Override - public String getContentType() throws MessagingException - { + public String getContentType() { return mContentType; } - public void setSubType(String subType) throws MessagingException - { + public void setSubType(String subType) { this.mSubType = subType; mContentType = String.format("multipart/%s; boundary=\"%s\"", subType, mBoundary); } diff --git a/src/com/fsck/k9/mail/store/ImapStore.java b/src/com/fsck/k9/mail/store/ImapStore.java index ee8dd8be3..2e5d89daa 100644 --- a/src/com/fsck/k9/mail/store/ImapStore.java +++ b/src/com/fsck/k9/mail/store/ImapStore.java @@ -216,8 +216,7 @@ public class ImapStore extends Store } @Override - public Folder getFolder(String name) throws MessagingException - { + public Folder getFolder(String name) { ImapFolder folder; synchronized (mFolderCache) { @@ -667,8 +666,7 @@ public class ImapStore extends Store } @Override - public OpenMode getMode() throws MessagingException - { + public OpenMode getMode() { return mMode; } @@ -1497,8 +1495,7 @@ public class ImapStore extends Store } @Override - public Flag[] getPermanentFlags() throws MessagingException - { + public Flag[] getPermanentFlags() { return PERMANENT_FLAGS; } @@ -2015,9 +2012,7 @@ public class ImapStore extends Store } } - private MessagingException ioExceptionHandler(ImapConnection connection, IOException ioe) - throws MessagingException - { + private MessagingException ioExceptionHandler(ImapConnection connection, IOException ioe) { Log.e(K9.LOG_TAG, "IOException for " + getLogId(), ioe); if (connection != null) { @@ -2587,8 +2582,7 @@ public class ImapStore extends Store return readResponse(null); } - private ImapResponse readResponse(ImapResponseParser.IImapResponseCallback callback) throws IOException, MessagingException - { + private ImapResponse readResponse(ImapResponseParser.IImapResponseCallback callback) throws IOException { try { ImapResponse response = mParser.readResponse(callback); @@ -2865,7 +2859,7 @@ public class ImapStore extends Store } private void sendContinuation(String continuation) - throws MessagingException, IOException + throws IOException { ImapConnection conn = mConnection; if (conn != null) diff --git a/src/com/fsck/k9/mail/store/LocalStore.java b/src/com/fsck/k9/mail/store/LocalStore.java index 04e6921e7..2cb7051cd 100644 --- a/src/com/fsck/k9/mail/store/LocalStore.java +++ b/src/com/fsck/k9/mail/store/LocalStore.java @@ -947,8 +947,7 @@ public class LocalStore extends Store implements Serializable, LocalStoreMigrati } @Override - public LocalFolder getFolder(String name) throws MessagingException - { + public LocalFolder getFolder(String name) { return new LocalFolder(name); } @@ -1805,8 +1804,7 @@ public class LocalStore extends Store implements Serializable, LocalStoreMigrati } @Override - public OpenMode getMode() throws MessagingException - { + public OpenMode getMode() { return OpenMode.READ_WRITE; } @@ -3572,8 +3570,7 @@ public class LocalStore extends Store implements Serializable, LocalStoreMigrati } @Override - public Flag[] getPermanentFlags() throws MessagingException - { + public Flag[] getPermanentFlags() { return PERMANENT_FLAGS; } @@ -5892,8 +5889,7 @@ public class LocalStore extends Store implements Serializable, LocalStoreMigrati super(body); } - public LocalTextBody(String body, String bodyForDisplay) throws MessagingException - { + public LocalTextBody(String body, String bodyForDisplay) { super(body); this.mBodyForDisplay = bodyForDisplay; } @@ -5931,8 +5927,7 @@ public class LocalStore extends Store implements Serializable, LocalStoreMigrati { } - LocalMessage(String uid, Folder folder) throws MessagingException - { + LocalMessage(String uid, Folder folder) { this.mUid = uid; this.mFolder = folder; } @@ -6344,8 +6339,7 @@ public class LocalStore extends Store implements Serializable, LocalStoreMigrati } } - private void updateFolderCountsOnFlag(Flag flag, boolean set) throws MessagingException - { + private void updateFolderCountsOnFlag(Flag flag, boolean set) { /* * Update the unread count on the folder. */ diff --git a/src/com/fsck/k9/mail/store/Pop3Store.java b/src/com/fsck/k9/mail/store/Pop3Store.java index abf6cf966..bb8a7aaf0 100644 --- a/src/com/fsck/k9/mail/store/Pop3Store.java +++ b/src/com/fsck/k9/mail/store/Pop3Store.java @@ -147,8 +147,7 @@ public class Pop3Store extends Store } @Override - public Folder getFolder(String name) throws MessagingException - { + public Folder getFolder(String name) { Folder folder = mFolders.get(name); if (folder == null) { @@ -330,8 +329,7 @@ public class Pop3Store extends Store } @Override - public OpenMode getMode() throws MessagingException - { + public OpenMode getMode() { return OpenMode.READ_WRITE; } @@ -863,8 +861,7 @@ public class Pop3Store extends Store } @Override - public Flag[] getPermanentFlags() throws MessagingException - { + public Flag[] getPermanentFlags() { return PERMANENT_FLAGS; } @@ -985,8 +982,7 @@ public class Pop3Store extends Store mOut.flush(); } - private Pop3Capabilities getCapabilities() throws IOException, MessagingException - { + private Pop3Capabilities getCapabilities() throws IOException { Pop3Capabilities capabilities = new Pop3Capabilities(); try { @@ -1103,8 +1099,7 @@ public class Pop3Store extends Store class Pop3Message extends MimeMessage { - public Pop3Message(String uid, Pop3Folder folder) throws MessagingException - { + public Pop3Message(String uid, Pop3Folder folder) { mUid = uid; mFolder = folder; mSize = -1; diff --git a/src/com/fsck/k9/mail/store/StorageManager.java b/src/com/fsck/k9/mail/store/StorageManager.java index 72853e9ce..a695d3601 100644 --- a/src/com/fsck/k9/mail/store/StorageManager.java +++ b/src/com/fsck/k9/mail/store/StorageManager.java @@ -550,8 +550,7 @@ public class StorageManager * @return Whether the specified file matches a filesystem root. * @throws IOException */ - public static boolean isMountPoint(final File file) throws IOException - { + public static boolean isMountPoint(final File file) { for (final File root : File.listRoots()) { if (root.equals(file)) diff --git a/src/com/fsck/k9/mail/store/WebDavStore.java b/src/com/fsck/k9/mail/store/WebDavStore.java index 88bbe2d46..98c168b86 100644 --- a/src/com/fsck/k9/mail/store/WebDavStore.java +++ b/src/com/fsck/k9/mail/store/WebDavStore.java @@ -349,8 +349,7 @@ public class WebDavStore extends Store } @Override - public Folder getFolder(String name) throws MessagingException - { + public Folder getFolder(String name) { WebDavFolder folder; if ((folder = this.mFolderList.get(name)) == null) @@ -1273,8 +1272,7 @@ public class WebDavStore extends Store } @Override - public OpenMode getMode() throws MessagingException - { + public OpenMode getMode() { return OpenMode.READ_WRITE; } @@ -1748,8 +1746,7 @@ public class WebDavStore extends Store } @Override - public Flag[] getPermanentFlags() throws MessagingException - { + public Flag[] getPermanentFlags() { return PERMANENT_FLAGS; } @@ -1855,15 +1852,9 @@ public class WebDavStore extends Store try { ByteArrayOutputStream out; - try - { - out = new ByteArrayOutputStream(message.getSize()); - } - catch (MessagingException e) - { - Log.e(K9.LOG_TAG, "MessagingException while getting size of message: " + e); - out = new ByteArrayOutputStream(); - } + + out = new ByteArrayOutputStream(message.getSize()); + open(OpenMode.READ_WRITE); EOLConvertingOutputStream msgOut = new EOLConvertingOutputStream( new BufferedOutputStream(out, 1024)); @@ -1952,8 +1943,7 @@ public class WebDavStore extends Store private String mUrl = ""; - WebDavMessage(String uid, Folder folder) throws MessagingException - { + WebDavMessage(String uid, Folder folder) { this.mUid = uid; this.mFolder = folder; } diff --git a/src/com/fsck/k9/preferences/Editor.java b/src/com/fsck/k9/preferences/Editor.java index 76626c740..62e966d05 100644 --- a/src/com/fsck/k9/preferences/Editor.java +++ b/src/com/fsck/k9/preferences/Editor.java @@ -72,8 +72,7 @@ public class Editor implements android.content.SharedPreferences.Editor } } - public void commitChanges() throws Exception - { + public void commitChanges() { long startTime = System.currentTimeMillis(); Log.i(K9.LOG_TAG, "Committing preference changes"); Runnable committer = new Runnable() diff --git a/src/com/fsck/k9/provider/MessageProvider.java b/src/com/fsck/k9/provider/MessageProvider.java index f0bedd0a9..3f2b13a08 100644 --- a/src/com/fsck/k9/provider/MessageProvider.java +++ b/src/com/fsck/k9/provider/MessageProvider.java @@ -982,8 +982,7 @@ public class MessageProvider extends ContentProvider K9.registerApplicationAware(new K9.ApplicationAware() { @Override - public void initializeComponent(final K9 application) throws Exception - { + public void initializeComponent(final K9 application) { Log.v(K9.LOG_TAG, "Registering content resolver notifier"); MessagingController.getInstance(application).addListener(new MessagingListener()