Hi guys!

In reading through the org.apache.catalina.resources package code, I found
a small omission from the ResourcesBase.setCheckInterval() method:

public void setCheckInterval(int checkInterval) {

  // Perform the property update
  int oldCheckInterval = this.checkInterval;
  this.checkInterval = checkInterval;
  support.firePropertyChange("checkInterval",
                 new Integer(oldCheckInterval),
                 new Integer(this.checkInterval));

  // Start or stop the background thread (if necessary)
  if (started) {
      if ((oldCheckInterval > 0) && (this.checkInterval <= 0))
          threadStop();
      else if ((oldCheckInterval <= 0) && (this.checkInterval > 0))
          threadStart();
  }

}


At the end of this method, we changed the check interval, and then we
need to either start or stop the background thread that periodically
checks for resource updates.  The code in this method handles the
following:

1. When the background thread is already running and we should be shutting
   it down because the new check interval doesn't require a background
   thread at all.
2. When the thread is supposedly already running, the old check interval
   didn't require a background thread (really, an illegal state -- and 
since
   this code looks basically like my patch below, was this just bad 
placement
   of this code?), and the new check interval does require a background
   thread..  In that case the code at least makes sure that we have
   a reference to a thread.

But, what it doesn't handle is:

3. When the background thread isn't already running, the previous check
   interval didn't require a background thread, and the new check interval
   does require a background thread..  It should start one.

So, here's the patch I'd suggest:

280a281,284
 >       else {
 >           if ((oldCheckInterval <= 0) && (this.checkInterval > 0))
 >               threadStart();
 >       }

Thanks!

-- 
Jason Brittain                          (415)354-6645
Software Engineer, Olliance Inc.        http://www.Olliance.com
Current Maintainer, Locomotive Project  http://www.Locomotive.org

Reply via email to