javax.mail.FolderClosedException Java Examples

The following examples show how to use javax.mail.FolderClosedException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Core.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
void error(Throwable ex) {
    if (ex instanceof MessagingException &&
            ("connection failure".equals(ex.getMessage()) ||
                    "Not connected".equals(ex.getMessage()) || // POP3
                    ex.getCause() instanceof SocketException ||
                    ex.getCause() instanceof ConnectionException))
        recoverable = false;

    if (ex instanceof ConnectionException)
        // failed to create new store connection
        // BYE, Socket is closed
        recoverable = false;

    if (ex instanceof StoreClosedException ||
            ex instanceof FolderClosedException ||
            ex instanceof FolderNotFoundException)
        // Lost folder connection to server
        recoverable = false;

    if (ex instanceof IllegalStateException && (
            "Not connected".equals(ex.getMessage()) ||
                    "This operation is not allowed on a closed folder".equals(ex.getMessage())))
        recoverable = false;

    if (ex instanceof OperationCanceledException)
        recoverable = false;

    thread.interrupt();
    yield();
}
 
Example #2
Source File: Log.java    From FairEmail with GNU General Public License v3.0 4 votes vote down vote up
static String formatThrowable(Throwable ex, String separator, boolean sanitize) {
    if (sanitize) {
        if (ex instanceof MessageRemovedException)
            return null;

        if (ex instanceof AuthenticationFailedException &&
                ex.getCause() instanceof SocketException)
            return null;

        if (ex instanceof MessagingException &&
                ("connection failure".equals(ex.getMessage()) ||
                        "failed to create new store connection".equals(ex.getMessage())))
            return null;

        if (ex instanceof MessagingException &&
                ex.getCause() instanceof ConnectionException &&
                ex.getCause().getMessage() != null &&
                (ex.getCause().getMessage().contains("Read error") ||
                        ex.getCause().getMessage().contains("Write error") ||
                        ex.getCause().getMessage().contains("Unexpected end of ZLIB input stream") ||
                        ex.getCause().getMessage().contains("Socket is closed")))
            return null;

        // javax.mail.MessagingException: AU3 BAD User is authenticated but not connected.;
        //   nested exception is:
        //  com.sun.mail.iap.BadCommandException: AU3 BAD User is authenticated but not connected.
        // javax.mail.MessagingException: AU3 BAD User is authenticated but not connected.;
        //   nested exception is:
        // 	com.sun.mail.iap.BadCommandException: AU3 BAD User is authenticated but not connected.
        // 	at com.sun.mail.imap.IMAPFolder.logoutAndThrow(SourceFile:1156)
        // 	at com.sun.mail.imap.IMAPFolder.open(SourceFile:1063)
        // 	at com.sun.mail.imap.IMAPFolder.open(SourceFile:977)
        // 	at eu.faircode.email.ServiceSynchronize.monitorAccount(SourceFile:890)
        // 	at eu.faircode.email.ServiceSynchronize.access$1500(SourceFile:85)
        // 	at eu.faircode.email.ServiceSynchronize$7$1.run(SourceFile:627)
        // 	at java.lang.Thread.run(Thread.java:764)
        // Caused by: com.sun.mail.iap.BadCommandException: AU3 BAD User is authenticated but not connected.
        // 	at com.sun.mail.iap.Protocol.handleResult(SourceFile:415)
        // 	at com.sun.mail.imap.protocol.IMAPProtocol.select(SourceFile:1230)
        // 	at com.sun.mail.imap.IMAPFolder.open(SourceFile:1034)

        if (ex instanceof MessagingException &&
                ex.getCause() instanceof BadCommandException &&
                ex.getCause().getMessage() != null &&
                ex.getCause().getMessage().contains("User is authenticated but not connected"))
            return null;

        if (ex instanceof IOException &&
                ex.getCause() instanceof MessageRemovedException)
            return null;

        if (ex instanceof ConnectionException)
            return null;

        if (ex instanceof StoreClosedException ||
                ex instanceof FolderClosedException || ex instanceof FolderClosedIOException)
            return null;

        if (ex instanceof IllegalStateException &&
                ("Not connected".equals(ex.getMessage()) ||
                        "This operation is not allowed on a closed folder".equals(ex.getMessage())))
            return null;
    }

    StringBuilder sb = new StringBuilder();
    if (BuildConfig.DEBUG)
        sb.append(ex.toString());
    else
        sb.append(ex.getMessage() == null ? ex.getClass().getName() : ex.getMessage());

    Throwable cause = ex.getCause();
    while (cause != null) {
        if (BuildConfig.DEBUG)
            sb.append(separator).append(cause.toString());
        else
            sb.append(separator).append(cause.getMessage() == null ? cause.getClass().getName() : cause.getMessage());
        cause = cause.getCause();
    }

    return sb.toString();
}
 
Example #3
Source File: POP3MockFolder.java    From javamail-mock2 with Apache License 2.0 3 votes vote down vote up
protected synchronized void checkOpened() throws FolderClosedException {

        if (!opened) {

            throw new IllegalStateException("This operation is not allowed on a closed folder " + objectId);

        }
    }
 
Example #4
Source File: IMAPMockFolder.java    From javamail-mock2 with Apache License 2.0 3 votes vote down vote up
@Override
protected void checkOpened() throws FolderClosedException {

    if (!opened) {

        throw new IllegalStateException("This operation is not allowed on a closed folder: " + getFullName() + " (" + objectId + ")");

    }
}