From c03ff7056803f170b960347f4ce90a5e74b755a7 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 8 Aug 2018 08:09:53 +0000 Subject: [PATCH] Skip reporting timeout exception --- .../eu/faircode/email/ServiceSynchronize.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index f96afea6..bc2b7a59 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -51,6 +51,7 @@ import org.json.JSONException; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; +import java.net.SocketTimeoutException; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -887,18 +888,26 @@ public class ServiceSynchronize extends LifecycleService { // There is no use in repeating operation.deleteOperation(op.id); } catch (SMTPSendFailedException ex) { - // Response codes: https://www.ietf.org/rfc/rfc821.txt + // TODO: response codes: https://www.ietf.org/rfc/rfc821.txt Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); // There is probably no use in repeating operation.deleteOperation(op.id); - reportError(null, folder.name, ex); + throw ex; + } catch (MessagingException ex) { + // Socket timeout is a recoverable condition (send message) + if (ex.getCause() instanceof SocketTimeoutException) { + Log.w(Helper.TAG, "Recoverable " + ex); + // No need to inform user + return; + } else + throw ex; } catch (NullPointerException ex) { Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); // There is no use in repeating operation.deleteOperation(op.id); - reportError(null, folder.name, ex); + throw ex; } } finally { Log.i(Helper.TAG, folder.name + " end op=" + op.id + "/" + op.name);