james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject cvs commit: jakarta-james/src/java/org/apache/mailet SpoolRepository.java
Date Tue, 04 Feb 2003 21:05:45 GMT
noel        2003/02/04 13:05:45

  Modified:    src/java/org/apache/james/mailrepository
                        AvalonSpoolRepository.java JDBCMailRepository.java
                        JDBCSpoolRepository.java
               src/java/org/apache/mailet SpoolRepository.java
  Log:
  made SpoolRepository.accept() interruptable; logged 'impossible' exceptions
  
  Revision  Changes    Path
  1.13      +14 -8     jakarta-james/src/java/org/apache/james/mailrepository/AvalonSpoolRepository.java
  
  Index: AvalonSpoolRepository.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/mailrepository/AvalonSpoolRepository.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- AvalonSpoolRepository.java	14 Jan 2003 13:58:21 -0000	1.12
  +++ AvalonSpoolRepository.java	4 Feb 2003 21:05:41 -0000	1.13
  @@ -38,11 +38,11 @@
        *
        * @return the key for the mail
        */
  -    public synchronized String accept() {
  +    public synchronized String accept() throws InterruptedException {
           if ((DEEP_DEBUG) && (getLogger().isDebugEnabled())) {
               getLogger().debug("Method accept() called");
           }
  -        while (true) {
  +        while (!Thread.currentThread().isInterrupted()) {
               try {
                   for(Iterator it = list(); it.hasNext(); ) {
   
  @@ -64,11 +64,14 @@
                   }
   
                   wait();
  -            } catch (InterruptedException ignored) {
  -            } catch (ConcurrentModificationException ignoredAlso) {
  +            } catch (InterruptedException ex) {
  +                throw ex;
  +            } catch (ConcurrentModificationException cme) {
                  // Should never get here now that list methods clones keyset for iterator
  +                getLogger().error("CME in spooler - please report to http://james.apache.org",
cme);
               }
           }
  +        throw new InterruptedException();
       }
   
       /**
  @@ -82,11 +85,11 @@
        *
        * @return the key for the mail
        */
  -    public synchronized String accept(long delay) {
  +    public synchronized String accept(long delay) throws InterruptedException {
           if ((DEEP_DEBUG) && (getLogger().isDebugEnabled())) {
               getLogger().debug("Method accept(delay) called");
           }
  -        while (true) {
  +        while (!Thread.currentThread().isInterrupted()) {
               long youngest = 0;
               for (Iterator it = list(); it.hasNext(); ) {
                   String s = it.next().toString();
  @@ -137,10 +140,13 @@
                   } else {
                       wait(youngest - System.currentTimeMillis());
                   }
  -            } catch (InterruptedException ignored) {
  -            } catch (ConcurrentModificationException ignoredAlso) {
  +            } catch (InterruptedException ex) {
  +                throw ex;
  +            } catch (ConcurrentModificationException cme) {
                  // Should never get here now that list methods clones keyset for iterator
  +                getLogger().error("CME in spooler - please report to http://james.apache.org",
cme);
               }
           }
  +        throw new InterruptedException();
       }
   }
  
  
  
  1.39      +1 -1      jakarta-james/src/java/org/apache/james/mailrepository/JDBCMailRepository.java
  
  Index: JDBCMailRepository.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/mailrepository/JDBCMailRepository.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- JDBCMailRepository.java	2 Feb 2003 23:36:16 -0000	1.38
  +++ JDBCMailRepository.java	4 Feb 2003 21:05:41 -0000	1.39
  @@ -755,7 +755,7 @@
               rsListMessages = listMessages.executeQuery();
   
               List messageList = new ArrayList();
  -            while (rsListMessages.next() /* && !Thread.currentThread().isInterrupted()
-- post 2.1 enable this (NjB) */) {
  +            while (rsListMessages.next() && !Thread.currentThread().isInterrupted())
{
                   messageList.add(rsListMessages.getString(1));
               }
               return messageList.iterator();
  
  
  
  1.19      +13 -10    jakarta-james/src/java/org/apache/james/mailrepository/JDBCSpoolRepository.java
  
  Index: JDBCSpoolRepository.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/mailrepository/JDBCSpoolRepository.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- JDBCSpoolRepository.java	14 Jan 2003 13:58:21 -0000	1.18
  +++ JDBCSpoolRepository.java	4 Feb 2003 21:05:41 -0000	1.19
  @@ -95,12 +95,12 @@
       /**
        * Return the key of a message to process.  This is a message in the spool that is
not locked.
        */
  -    public String accept() {
  -        while (true) {
  +    public String accept() throws InterruptedException {
  +        while (!Thread.currentThread().isInterrupted()) {
               //Loop through until we are either out of pending messages or have a message
               // that we can lock
               PendingMessage next = null;
  -            while ((next = getNextPendingMessage()) != null) {
  +            while ((next = getNextPendingMessage()) != null && !Thread.currentThread().isInterrupted())
{
                   if (lock(next.key)) {
                       return next.key;
                   }
  @@ -117,9 +117,11 @@
                       //System.err.println(errorBuffer.toString());
                       wait(WAIT_LIMIT);
                   }
  -            } catch (InterruptedException ignored) {
  +            } catch (InterruptedException ex) {
  +                throw ex;
               }
           }
  +        throw new InterruptedException();
       }
   
       /**
  @@ -127,13 +129,13 @@
        * then check the last updated time, and don't try it until the long 'delay' parameter
        * milliseconds has passed.
        */
  -    public synchronized String accept(long delay) {
  -        while (true) {
  +    public synchronized String accept(long delay) throws InterruptedException {
  +        while (!Thread.currentThread().isInterrupted()) {
               //Loop through until we are either out of pending messages or have a message
               // that we can lock
               PendingMessage next = null;
               long sleepUntil = 0;
  -            while ((next = getNextPendingMessage()) != null) {
  +            while ((next = getNextPendingMessage()) != null && !Thread.currentThread().isInterrupted())
{
                   //Check whether this is time to expire
                   boolean shouldProcess = false;
                   if (Mail.ERROR.equals(next.state)) {
  @@ -172,10 +174,11 @@
                       //System.err.println(errorBuffer.toString());
                       wait(waitTime);
                   }
  -            } catch (InterruptedException ignored) {
  +            } catch (InterruptedException ex) {
  +                throw ex;
               }
  -
           }
  +        throw new InterruptedException();
       }
   
       /**
  @@ -233,7 +236,7 @@
                   //  a possible message, or we retrieve 1000 messages.  This 1000 cap is
to
                   //  avoid loading thousands or hundreds of thousands of messages when the
                   //  spool is enourmous.
  -                while (rsListMessages.next() && pendingMessages.size() < 1000)
{
  +                while (rsListMessages.next() && pendingMessages.size() < 1000
&& !Thread.currentThread().isInterrupted()) {
                       String key = rsListMessages.getString(1);
                       String state = rsListMessages.getString(2);
                       long lastUpdated = rsListMessages.getTimestamp(3).getTime();
  
  
  
  1.4       +2 -2      jakarta-james/src/java/org/apache/mailet/SpoolRepository.java
  
  Index: SpoolRepository.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/mailet/SpoolRepository.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SpoolRepository.java	14 Jan 2003 13:42:10 -0000	1.3
  +++ SpoolRepository.java	4 Feb 2003 21:05:43 -0000	1.4
  @@ -30,7 +30,7 @@
        *
        * @return the key for the mail
        */
  -    String accept();
  +    String accept() throws InterruptedException;
   
       /**
        * Returns the key for an arbitrarily select mail deposited in this Repository that
  @@ -41,5 +41,5 @@
        *
        * @return the key for the mail
        */
  -    String accept(long delay);
  +    String accept(long delay) throws InterruptedException;
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org


Mime
View raw message