Uploaded image for project: 'Mule'
  1. Mule
  2. MULE-2624

Problems reconnecting to POP3 server

    Details

    • Type: Bug
    • Status: Closed
    • Priority: To be reviewed
    • Resolution: Won't Fix or Usage Issue
    • Affects Version/s: 1.4.3
    • Fix Version/s: None
    • Component/s: Transport: Email
    • Labels:
      None
    • Environment:

      All, SUN's implementation of javax-mail

    • Configuration:
      Hide
      <connector name="InboxPop3Connector" className="org.mule.providers.email.Pop3Connector">
         <properties>
            <property name="checkFrequency" value="10000"/>
         </properties>
      </connector>
      
      Show
      <connector name= "InboxPop3Connector" className= "org.mule.providers.email.Pop3Connector" > <properties> <property name= "checkFrequency" value= "10000" /> </properties> </connector>
    • Log Output:
      Hide
      {code}
      12:48:16.796 ERROR {InboxPop3Connector.scheduler.1} [DefaultExceptionStrategy] : Caught exception in Exception Strategy: Folder not open
      java.lang.IllegalStateException: Folder not open
              at javax.mail.Folder.getMessages(Folder.java:925)
              at org.mule.providers.email.RetrieveMessageReceiver.poll(RetrieveMessageReceiver.java:304)
              at org.mule.providers.AbstractPollingMessageReceiver.run(AbstractPollingMessageReceiver.java:115)
              at edu.emory.mathcs.backport.java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
              at edu.emory.mathcs.backport.java.util.concurrent.FutureTask.runAndReset(FutureTask.java:198)
              at edu.emory.mathcs.backport.java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:138)
              at edu.emory.mathcs.backport.java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:238)
              at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:987)
              at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:528)
              at java.lang.Thread.run(Thread.java:595)
      {code}
      Show
      {code} 12:48:16.796 ERROR {InboxPop3Connector.scheduler.1} [DefaultExceptionStrategy] : Caught exception in Exception Strategy: Folder not open java.lang.IllegalStateException: Folder not open         at javax.mail.Folder.getMessages(Folder.java:925)         at org.mule.providers.email.RetrieveMessageReceiver.poll(RetrieveMessageReceiver.java:304)         at org.mule.providers.AbstractPollingMessageReceiver.run(AbstractPollingMessageReceiver.java:115)         at edu.emory.mathcs.backport.java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)         at edu.emory.mathcs.backport.java.util.concurrent.FutureTask.runAndReset(FutureTask.java:198)         at edu.emory.mathcs.backport.java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:138)         at edu.emory.mathcs.backport.java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:238)         at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:987)         at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:528)         at java.lang.Thread.run(Thread.java:595) {code}

      Description

      Problems with POP3 Message Receiver due to connection reset in one particular moment.
      In org.mule.providers.email.RetrieveMessageReceiver.poll() method, after succesfully opening the folder and retrieving the number of messages:

      if (!folder.isOpen())
      {
         folder.open(Folder.READ_WRITE);
      }
      //...
      int count = folder.getMessageCount();
      if (count > 0)
      {
      

      when the connection to pop3 server is closed, com.sun.mail.pop3.POP3Folder.getMessages() causes closing POP3Store, because of this simple exception:

      java.net.SocketException: Software caused connection abort: recv failed
      	at java.net.SocketInputStream.socketRead0(Native Method)
      	at java.net.SocketInputStream.read(SocketInputStream.java:129)
      	at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
      	at java.io.BufferedInputStream.read(BufferedInputStream.java:235)
      	at java.io.DataInputStream.readLine(DataInputStream.java:473)
      	at com.sun.mail.pop3.Protocol.simpleCommand(Protocol.java:347)
      	at com.sun.mail.pop3.Protocol.noop(Protocol.java:322)
      	at com.sun.mail.pop3.POP3Store.isConnected(POP3Store.java:176)
      	at com.sun.mail.pop3.POP3Folder.isOpen(POP3Folder.java:260)
      	at javax.mail.Folder.getMessages(Folder.java:924)
      

      Then there is an IllegalStateException in the following code:

      try
      {
         folder.close(true); // close and expunge deleted messages
      }
      catch (Exception e)
      {
         logger.error("Failed to close pop3  inbox: " + e.getMessage());
      }
      

      because the folder and the store have been closed().

      Now, when the connection to POP3 server is back, the folder is succesfully opened:

      folder.open(Folder.READ_WRITE);
      

      but getMessages() throws an java.lang.IllegalStateException, because POP3Store is still closed.

      RetrieveMessageReceiver is not able to perform reconnection, because getMessages() throws IllegalStateException instead of MessagingException and handleException() is never called.

      It still wouldn't change anything, because IllegalStateException is not instanceof org.mule.providers.ConnectException.

      Please add some method of performing reconnection in case of such error.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              gzress Grzegorz Grzybek
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • It looks like Backbone Issue Sync is not enabled for your project.