Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-2231

Exception during mail connection requires folder to be reset

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6.2, 2.0.0
    • 1.6.3, 2.1.0
    • camel-mail
    • None
    • 2.1-SNAPSHOT

    Description

      I think that this problem may still be around with 2.1-SNAPSHOT:

      http://fusesource.com/forums/thread.jspa?threadID=746&tstart=0

      I noticed that I had a pop3 server outage and then subsequently had a similar problem i.e. IllegalStateException, folder not open.

      Here's when the outage started.

      2009-11-26 11:57:55,316 [: MailComponent] WARN  ultPollingConsumerPollStrategy - Consumer Consumer[pop3://...] could not poll endpoint: pop3://... caused by: Connect failed
      javax.mail.MessagingException: Connect failed;
        nested exception is:
              java.net.NoRouteToHostException: No route to host
              at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:161)
              at javax.mail.Service.connect(Service.java:288)
              at org.apache.camel.component.mail.MailConsumer.ensureIsConnected(MailConsumer.java:241)
              at org.apache.camel.component.mail.MailConsumer.poll(MailConsumer.java:79)
              at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:108)
              at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
              at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
              at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
              at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
              at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
              at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
              at java.lang.Thread.run(Thread.java:619)
      Caused by: java.net.NoRouteToHostException: No route to host
              at java.net.PlainSocketImpl.socketConnect(Native Method)
              at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
              at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
              at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
              at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
              at java.net.Socket.connect(Socket.java:519)
              at java.net.Socket.connect(Socket.java:469)
              at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)
              at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
              at com.sun.mail.pop3.Protocol.<init>(Protocol.java:94)
              at com.sun.mail.pop3.POP3Store.getPort(POP3Store.java:214)
              at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:157)
              ... 13 more
      

      This went on for about a minute or so and there was no more in the log file until several hours later - in fact when an email appeared in the INBOX. I know this because my personal email account was copied on the email and so I have the timestamp.

      I then get the following message every time I poll the server and have to re-start my application to get over it:

      2009-11-26 19:19:57,293 [: MailComponent] ERROR MailConsumer                   - Folder not open
      java.lang.IllegalStateException: Folder not open
              at javax.mail.Folder.getMessages(Folder.java:938)
              at javax.mail.Folder.search(Folder.java:1226)
              at org.apache.camel.component.mail.MailConsumer.poll(MailConsumer.java:107)
              at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:108)
              at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
              at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
              at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
              at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
              at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
              at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
              at java.lang.Thread.run(Thread.java:619)
      

      I took a look at MailConsumer.java and note the following code:

      236	        if (!connected) {
      237	            if (LOG.isDebugEnabled()) {
      238	                LOG.debug("Connecting to MailStore: " + endpoint.getConfiguration().getMailStoreLogInformation());
      239	            }
      240	            store = sender.getSession().getStore(config.getProtocol());
      241	            store.connect(config.getHost(), config.getPort(), config.getUsername(), config.getPassword());
      242	        }
      

      If you're not connected then how is it possible to have a folder? Following this logic my recommendation is to insert the following at line 242:

      241	            store.connect(config.getHost(), config.getPort(), config.getUsername(), config.getPassword());
                          folder = null;
      242	        }
      

      Attachments

        1. camel-mail-2.1-SNAPSHOT.jar
          48 kB
          Claus Ibsen

        Issue Links

          Activity

            People

              davsclaus Claus Ibsen
              huntc@internode.on.net Christopher Hunt
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 2h
                  2h
                  Remaining:
                  Remaining Estimate - 2h
                  2h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified