ceki        2004/12/09 04:49:00

  Modified:    src/java/org/apache/log4j/scheduler Scheduler.java
  Log:
  Chages ensuring clean operation while or after shutdown
  
  Revision  Changes    Path
  1.6       +15 -2     
logging-log4j/src/java/org/apache/log4j/scheduler/Scheduler.java
  
  Index: Scheduler.java
  ===================================================================
  RCS file: 
/home/cvs/logging-log4j/src/java/org/apache/log4j/scheduler/Scheduler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Scheduler.java    20 Nov 2004 18:03:37 -0000      1.5
  +++ Scheduler.java    9 Dec 2004 12:49:00 -0000       1.6
  @@ -31,7 +31,7 @@
    *
    */
   public class Scheduler extends Thread {
  -  // 
  +   
     List jobList;
     boolean shutdown = false;
     
  @@ -64,9 +64,15 @@
     
     /**
      * Delete the given job. Returns true if the job could be deleted, and 
  -   * false if the job could not be found.
  +   * false if the job could not be found or if the Scheduler is about to
  +   * shutdown in which case deletions are not permitted.
      */
     public synchronized boolean delete(Job job) {
  +    // if already shutdown in the process of shutdown, there is no
  +    // need to remove Jobs as they will never be executed.
  +    if(shutdown) {
  +      return false;
  +    }
       int i = findIndex(job);
       if(i != -1) {
         ScheduledJobEntry se = (ScheduledJobEntry) jobList.remove(i);
  @@ -128,6 +134,10 @@
     }
       
     private synchronized void schedule(ScheduledJobEntry newSJE) {
  +    // disallow new jobs after shutdown
  +    if(shutdown) {
  +      return;
  +    }
        int max = jobList.size();
        long desiredExecutionTime = newSJE.desiredExecutionTime;
        
  @@ -171,6 +181,9 @@
           }
         }
       }
  +    // clear out the job list to facilitate garbage collection
  +    jobList.clear();
  +    jobList = null;
       System.out.println("Leaving scheduler run method");
     }
     
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to