//# 2 errors, 383 messages
//#
/*
    //#TaskScheduler.java:1:1: class: org.apache.roller.weblogger.business.runnable.TaskScheduler
 * Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  The ASF licenses this file to You
 * under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.  For additional information regarding
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */

package org.apache.roller.weblogger.business.runnable;

import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.roller.util.DateUtil;
import org.apache.roller.weblogger.business.WebloggerFactory;
import org.apache.roller.weblogger.pojos.TaskLock;


/**
 * Manages scheduling of periodic tasks.
 * 
 * This scheduler is meant to be run on a single thread and once started it will
 * run continuously until the thread is interrupted.  The basic logic of the
 * scheduler is to accept some number of tasks to be run and once per minute
 * the scheduler will launch any tasks that need to be executed.  
 * 
 * Tasks are executed each on their own thread, so this scheduler does not run
 * serially like a TimerTask.  The threads used for running tasks are managed
 * by an instance of a ThreadPoolExecutor.
 */
public class TaskScheduler implements Runnable {
    
    private static Log log = LogFactory.getLog(TaskScheduler.class);
    //#TaskScheduler.java:47: method: org.apache.roller.weblogger.business.runnable.TaskScheduler.org.apache.roller.weblogger.business.runnable.TaskScheduler__static_init
    //#TaskScheduler.java:47: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: org.apache.roller.weblogger.business.runnable.TaskScheduler__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(org.apache.roller.weblogger.business.runnable.TaskScheduler__static_init): __Descendant_Table[org/apache/roller/weblogger/business/runnable/TaskScheduler]
    //#output(org.apache.roller.weblogger.business.runnable.TaskScheduler__static_init): __Dispatch_Table.run()V
    //#output(org.apache.roller.weblogger.business.runnable.TaskScheduler__static_init): __Dispatch_Table.runTasks(Ljava/util/Date;)V
    //#output(org.apache.roller.weblogger.business.runnable.TaskScheduler__static_init): log
    //#post(org.apache.roller.weblogger.business.runnable.TaskScheduler__static_init): __Descendant_Table[org/apache/roller/weblogger/business/runnable/TaskScheduler] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.business.runnable.TaskScheduler__static_init): __Dispatch_Table.run()V == &run
    //#post(org.apache.roller.weblogger.business.runnable.TaskScheduler__static_init): __Dispatch_Table.runTasks(Ljava/util/Date;)V == &runTasks
    //#post(org.apache.roller.weblogger.business.runnable.TaskScheduler__static_init): init'ed(log)
    //#TaskScheduler.java:47: end of method: org.apache.roller.weblogger.business.runnable.TaskScheduler.org.apache.roller.weblogger.business.runnable.TaskScheduler__static_init
    
    private static final long ONE_MINUTE_MS = (60 * 1000);
    
    private final ExecutorService pool;
    private final List<RollerTask> tasks;
    
    
    public TaskScheduler(List<RollerTask> webloggerTasks) {
    //#TaskScheduler.java:55: method: void org.apache.roller.weblogger.business.runnable.TaskScheduler.org.apache.roller.weblogger.business.runnable.TaskScheduler(List)
    //#input(void org.apache.roller.weblogger.business.runnable.TaskScheduler(List)): this
    //#input(void org.apache.roller.weblogger.business.runnable.TaskScheduler(List)): webloggerTasks
    //#output(void org.apache.roller.weblogger.business.runnable.TaskScheduler(List)): this.pool
    //#output(void org.apache.roller.weblogger.business.runnable.TaskScheduler(List)): this.tasks
    //#post(void org.apache.roller.weblogger.business.runnable.TaskScheduler(List)): init'ed(this.pool)
    //#post(void org.apache.roller.weblogger.business.runnable.TaskScheduler(List)): this.tasks == webloggerTasks
    //#post(void org.apache.roller.weblogger.business.runnable.TaskScheduler(List)): init'ed(this.tasks)
        
        // store list of tasks available to run
        tasks = webloggerTasks;
        
        // use an expanding thread executor pool
        pool = Executors.newCachedThreadPool();
    }
    //#TaskScheduler.java:62: end of method: void org.apache.roller.weblogger.business.runnable.TaskScheduler.org.apache.roller.weblogger.business.runnable.TaskScheduler(List)
    
    
    public void run() {
        
        boolean firstRun = true;
    //#TaskScheduler.java:67: method: void org.apache.roller.weblogger.business.runnable.TaskScheduler.run()
    //#TaskScheduler.java:67: Warning: suspicious precondition
    //#    the precondition for org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.__Tag is not a contiguous range of values
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void run()
    //#    suspicious precondition index: [3]
    //#    Attribs:  Soft
    //#input(void run()): ": LAUNCHING task"._tainted
    //#input(void run()): ": Unhandled exception caught"._tainted
    //#input(void run()): ": next allowed run time = "._tainted
    //#input(void run()): "Current time = "._tainted
    //#input(void run()): "PingQueueTask"._tainted
    //#input(void run()): "ResetHitCountsTask"._tainted
    //#input(void run()): "SKIPPING task : "._tainted
    //#input(void run()): "ScheduledEntriesTask"._tainted
    //#input(void run()): "Start time = "._tainted
    //#input(void run()): "Started - "._tainted
    //#input(void run()): "TurnoverReferersTask"._tainted
    //#input(void run()): "sleeping - "._tainted
    //#input(void run()): log
    //#input(void run()): org/apache/roller/weblogger/business/BookmarkManager.__Descendant_Table[org/apache/roller/weblogger/business/BookmarkManager]
    //#input(void run()): org/apache/roller/weblogger/business/BookmarkManager.__Descendant_Table[org/apache/roller/weblogger/business/jpa/JPABookmarkManagerImpl]
    //#input(void run()): org/apache/roller/weblogger/business/BookmarkManager.__Descendant_Table[others]
    //#input(void run()): org/apache/roller/weblogger/business/BookmarkManager.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/FileManager.__Descendant_Table[org/apache/roller/weblogger/business/FileManagerImpl]
    //#input(void run()): org/apache/roller/weblogger/business/FileManager.__Descendant_Table[org/apache/roller/weblogger/business/FileManager]
    //#input(void run()): org/apache/roller/weblogger/business/FileManager.__Descendant_Table[others]
    //#input(void run()): org/apache/roller/weblogger/business/FileManager.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/FileManagerImpl.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/GuiceWebloggerProvider.__Dispatch_Table.getWeblogger()Lorg/apache/roller/weblogger/business/Weblogger;
    //#input(void run()): org/apache/roller/weblogger/business/UserManager.__Descendant_Table[org/apache/roller/weblogger/business/UserManager]
    //#input(void run()): org/apache/roller/weblogger/business/UserManager.__Descendant_Table[org/apache/roller/weblogger/business/jpa/JPAUserManagerImpl]
    //#input(void run()): org/apache/roller/weblogger/business/UserManager.__Descendant_Table[others]
    //#input(void run()): org/apache/roller/weblogger/business/UserManager.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/WeblogManager.__Descendant_Table[org/apache/roller/weblogger/business/WeblogManager]
    //#input(void run()): org/apache/roller/weblogger/business/WeblogManager.__Descendant_Table[org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl]
    //#input(void run()): org/apache/roller/weblogger/business/WeblogManager.__Descendant_Table[others]
    //#input(void run()): org/apache/roller/weblogger/business/WeblogManager.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/Weblogger.__Descendant_Table[org/apache/roller/weblogger/business/WebloggerImpl]
    //#input(void run()): org/apache/roller/weblogger/business/Weblogger.__Descendant_Table[org/apache/roller/weblogger/business/Weblogger]
    //#input(void run()): org/apache/roller/weblogger/business/Weblogger.__Descendant_Table[org/apache/roller/weblogger/business/jpa/JPAWebloggerImpl]
    //#input(void run()): org/apache/roller/weblogger/business/Weblogger.__Descendant_Table[others]
    //#input(void run()): org/apache/roller/weblogger/business/Weblogger.__Dispatch_Table.getThreadManager()Lorg/apache/roller/weblogger/business/runnable/ThreadManager;
    //#input(void run()): org/apache/roller/weblogger/business/Weblogger.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.__Tag
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.__Tag
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.autoPingManager
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.autoPingManager.__Tag
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.bookmarkManager
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.bookmarkManager.__Tag
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.fileManager
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.fileManager.__Tag
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.pingQueueManager
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.pingQueueManager.__Tag
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.pingTargetManager
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.pingTargetManager.__Tag
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.pluginManager
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.pluginManager.__Tag
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.refererManager
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.refererManager.__Tag
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.strategy
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.strategy.__Tag
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.strategy.emf
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.strategy.threadLocalEntityManager
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.threadManager
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.threadManager.__Tag
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.threadManager.strategy
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.threadManager.strategy.__Tag
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.threadManager.strategy.threadLocalEntityManager
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.userManager
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.userManager.__Tag
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.weblogManager
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.weblogManager.__Tag
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerImpl.__Dispatch_Table.getThreadManager()Lorg/apache/roller/weblogger/business/runnable/ThreadManager;
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerImpl.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerImpl.log
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerProvider.__Descendant_Table[org/apache/roller/weblogger/business/GuiceWebloggerProvider]
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerProvider.__Descendant_Table[org/apache/roller/weblogger/business/WebloggerProvider]
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerProvider.__Descendant_Table[others]
    //#input(void run()): org/apache/roller/weblogger/business/WebloggerProvider.__Dispatch_Table.getWeblogger()Lorg/apache/roller/weblogger/business/Weblogger;
    //#input(void run()): org/apache/roller/weblogger/business/jpa/JPAAutoPingManagerImpl.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/jpa/JPABookmarkManagerImpl.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.__Descendant_Table[org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy]
    //#input(void run()): org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.__Descendant_Table[others]
    //#input(void run()): org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.__Dispatch_Table.getNamedQuery(Ljava/lang/String;)Ljavax/persistence/Query;
    //#input(void run()): org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.javax.persistence.FlushModeType.COMMIT
    //#input(void run()): org/apache/roller/weblogger/business/jpa/JPAPingQueueManagerImpl.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/jpa/JPAPingTargetManagerImpl.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/jpa/JPARefererManagerImpl.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/jpa/JPAThreadManagerImpl.__Dispatch_Table.getTaskLockByName(Ljava/lang/String;)Lorg/apache/roller/weblogger/pojos/TaskLock;
    //#input(void run()): org/apache/roller/weblogger/business/jpa/JPAThreadManagerImpl.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/jpa/JPAUserManagerImpl.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/jpa/JPAWebloggerImpl.__Dispatch_Table.getThreadManager()Lorg/apache/roller/weblogger/business/runnable/ThreadManager;
    //#input(void run()): org/apache/roller/weblogger/business/jpa/JPAWebloggerImpl.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/pings/AutoPingManager.__Descendant_Table[org/apache/roller/weblogger/business/jpa/JPAAutoPingManagerImpl]
    //#input(void run()): org/apache/roller/weblogger/business/pings/AutoPingManager.__Descendant_Table[org/apache/roller/weblogger/business/pings/AutoPingManager]
    //#input(void run()): org/apache/roller/weblogger/business/pings/AutoPingManager.__Descendant_Table[others]
    //#input(void run()): org/apache/roller/weblogger/business/pings/AutoPingManager.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/pings/PingQueueManager.__Descendant_Table[org/apache/roller/weblogger/business/jpa/JPAPingQueueManagerImpl]
    //#input(void run()): org/apache/roller/weblogger/business/pings/PingQueueManager.__Descendant_Table[org/apache/roller/weblogger/business/pings/PingQueueManager]
    //#input(void run()): org/apache/roller/weblogger/business/pings/PingQueueManager.__Descendant_Table[others]
    //#input(void run()): org/apache/roller/weblogger/business/pings/PingQueueManager.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/pings/PingQueueTask.__Dispatch_Table.getInterval()I
    //#input(void run()): org/apache/roller/weblogger/business/pings/PingQueueTask.__Dispatch_Table.getName()Ljava/lang/String;
    //#input(void run()): org/apache/roller/weblogger/business/pings/PingQueueTask.__Dispatch_Table.getStartTimeDesc()Ljava/lang/String;
    //#input(void run()): org/apache/roller/weblogger/business/pings/PingTargetManager.__Descendant_Table[org/apache/roller/weblogger/business/jpa/JPAPingTargetManagerImpl]
    //#input(void run()): org/apache/roller/weblogger/business/pings/PingTargetManager.__Descendant_Table[org/apache/roller/weblogger/business/pings/PingTargetManager]
    //#input(void run()): org/apache/roller/weblogger/business/pings/PingTargetManager.__Descendant_Table[others]
    //#input(void run()): org/apache/roller/weblogger/business/pings/PingTargetManager.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/plugins/PluginManager.__Descendant_Table[org/apache/roller/weblogger/business/plugins/PluginManagerImpl]
    //#input(void run()): org/apache/roller/weblogger/business/plugins/PluginManager.__Descendant_Table[org/apache/roller/weblogger/business/plugins/PluginManager]
    //#input(void run()): org/apache/roller/weblogger/business/plugins/PluginManager.__Descendant_Table[others]
    //#input(void run()): org/apache/roller/weblogger/business/plugins/PluginManager.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/plugins/PluginManagerImpl.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/referrers/RefererManager.__Descendant_Table[org/apache/roller/weblogger/business/jpa/JPARefererManagerImpl]
    //#input(void run()): org/apache/roller/weblogger/business/referrers/RefererManager.__Descendant_Table[org/apache/roller/weblogger/business/referrers/RefererManager]
    //#input(void run()): org/apache/roller/weblogger/business/referrers/RefererManager.__Descendant_Table[others]
    //#input(void run()): org/apache/roller/weblogger/business/referrers/RefererManager.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/runnable/ResetHitCountsTask.__Dispatch_Table.getInterval()I
    //#input(void run()): org/apache/roller/weblogger/business/runnable/ResetHitCountsTask.__Dispatch_Table.getName()Ljava/lang/String;
    //#input(void run()): org/apache/roller/weblogger/business/runnable/ResetHitCountsTask.__Dispatch_Table.getStartTimeDesc()Ljava/lang/String;
    //#input(void run()): org/apache/roller/weblogger/business/runnable/RollerTask.__Descendant_Table[org/apache/roller/weblogger/business/pings/PingQueueTask]
    //#input(void run()): org/apache/roller/weblogger/business/runnable/RollerTask.__Descendant_Table[org/apache/roller/weblogger/business/runnable/ResetHitCountsTask]
    //#input(void run()): org/apache/roller/weblogger/business/runnable/RollerTask.__Descendant_Table[org/apache/roller/weblogger/business/runnable/RollerTaskWithLeasing]
    //#input(void run()): org/apache/roller/weblogger/business/runnable/RollerTask.__Descendant_Table[org/apache/roller/weblogger/business/runnable/RollerTask]
    //#input(void run()): org/apache/roller/weblogger/business/runnable/RollerTask.__Descendant_Table[org/apache/roller/weblogger/business/runnable/ScheduledEntriesTask]
    //#input(void run()): org/apache/roller/weblogger/business/runnable/RollerTask.__Descendant_Table[org/apache/roller/weblogger/business/runnable/TurnoverReferersTask]
    //#input(void run()): org/apache/roller/weblogger/business/runnable/RollerTask.__Descendant_Table[others]
    //#input(void run()): org/apache/roller/weblogger/business/runnable/RollerTask.__Dispatch_Table.getInterval()I
    //#input(void run()): org/apache/roller/weblogger/business/runnable/RollerTask.__Dispatch_Table.getName()Ljava/lang/String;
    //#input(void run()): org/apache/roller/weblogger/business/runnable/RollerTask.__Dispatch_Table.getStartTimeDesc()Ljava/lang/String;
    //#input(void run()): org/apache/roller/weblogger/business/runnable/RollerTaskWithLeasing.__Dispatch_Table.getInterval()I
    //#input(void run()): org/apache/roller/weblogger/business/runnable/RollerTaskWithLeasing.__Dispatch_Table.getName()Ljava/lang/String;
    //#input(void run()): org/apache/roller/weblogger/business/runnable/RollerTaskWithLeasing.__Dispatch_Table.getStartTimeDesc()Ljava/lang/String;
    //#input(void run()): org/apache/roller/weblogger/business/runnable/ScheduledEntriesTask.__Dispatch_Table.getInterval()I
    //#input(void run()): org/apache/roller/weblogger/business/runnable/ScheduledEntriesTask.__Dispatch_Table.getName()Ljava/lang/String;
    //#input(void run()): org/apache/roller/weblogger/business/runnable/ScheduledEntriesTask.__Dispatch_Table.getStartTimeDesc()Ljava/lang/String;
    //#input(void run()): org/apache/roller/weblogger/business/runnable/ThreadManager.__Descendant_Table[org/apache/roller/weblogger/business/jpa/JPAThreadManagerImpl]
    //#input(void run()): org/apache/roller/weblogger/business/runnable/ThreadManager.__Descendant_Table[org/apache/roller/weblogger/business/runnable/ThreadManagerImpl]
    //#input(void run()): org/apache/roller/weblogger/business/runnable/ThreadManager.__Descendant_Table[org/apache/roller/weblogger/business/runnable/ThreadManager]
    //#input(void run()): org/apache/roller/weblogger/business/runnable/ThreadManager.__Descendant_Table[others]
    //#input(void run()): org/apache/roller/weblogger/business/runnable/ThreadManager.__Dispatch_Table.getTaskLockByName(Ljava/lang/String;)Lorg/apache/roller/weblogger/pojos/TaskLock;
    //#input(void run()): org/apache/roller/weblogger/business/runnable/ThreadManager.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/runnable/ThreadManagerImpl.__Dispatch_Table.getTaskLockByName(Ljava/lang/String;)Lorg/apache/roller/weblogger/pojos/TaskLock;
    //#input(void run()): org/apache/roller/weblogger/business/runnable/ThreadManagerImpl.__Dispatch_Table.release()V
    //#input(void run()): org/apache/roller/weblogger/business/runnable/TurnoverReferersTask.__Dispatch_Table.getInterval()I
    //#input(void run()): org/apache/roller/weblogger/business/runnable/TurnoverReferersTask.__Dispatch_Table.getName()Ljava/lang/String;
    //#input(void run()): org/apache/roller/weblogger/business/runnable/TurnoverReferersTask.__Dispatch_Table.getStartTimeDesc()Ljava/lang/String;
    //#input(void run()): this
    //#input(void run()): this.pool
    //#input(void run()): this.tasks
    //#pre[14] (void run()): this.pool != null
    //#pre[1] (void run()): (soft) log != null
    //#pre[2] (void run()): (soft) org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider != null
    //#pre[3] (void run()): (soft) org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.__Tag in {org/apache/roller/weblogger/business/GuiceWebloggerProvider, org/apache/roller/weblogger/business/WebloggerProvider}
    //#pre[4] (void run()): (soft) org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance != null
    //#pre[12] (void run()): (soft) org/apache/roller/weblogger/business/WebloggerImpl.log != null
    //#pre[15] (void run()): (soft) this.tasks != null
    //#presumption(void run()): getWeblogger(...).__Tag in {org/apache/roller/weblogger/business/Weblogger, org/apache/roller/weblogger/business/WebloggerImpl, org/apache/roller/weblogger/business/jpa/JPAWebloggerImpl}
    //#presumption(void run()): getWeblogger(...).autoPingManager != null
    //#presumption(void run()): getWeblogger(...).autoPingManager.__Tag in {org/apache/roller/weblogger/business/jpa/JPAAutoPingManagerImpl, org/apache/roller/weblogger/business/pings/AutoPingManager}
    //#presumption(void run()): getWeblogger(...).bookmarkManager != null
    //#presumption(void run()): getWeblogger(...).bookmarkManager.__Tag in {org/apache/roller/weblogger/business/BookmarkManager, org/apache/roller/weblogger/business/jpa/JPABookmarkManagerImpl}
    //#presumption(void run()): getWeblogger(...).fileManager != null
    //#presumption(void run()): getWeblogger(...).fileManager.__Tag in {org/apache/roller/weblogger/business/FileManager, org/apache/roller/weblogger/business/FileManagerImpl}
    //#presumption(void run()): getWeblogger(...).pingQueueManager != null
    //#presumption(void run()): getWeblogger(...).pingQueueManager.__Tag in {org/apache/roller/weblogger/business/jpa/JPAPingQueueManagerImpl, org/apache/roller/weblogger/business/pings/PingQueueManager}
    //#presumption(void run()): getWeblogger(...).pingTargetManager != null
    //#presumption(void run()): getWeblogger(...).pingTargetManager.__Tag in {org/apache/roller/weblogger/business/jpa/JPAPingTargetManagerImpl, org/apache/roller/weblogger/business/pings/PingTargetManager}
    //#presumption(void run()): getWeblogger(...).pluginManager != null
    //#presumption(void run()): getWeblogger(...).pluginManager.__Tag in {org/apache/roller/weblogger/business/plugins/PluginManager, org/apache/roller/weblogger/business/plugins/PluginManagerImpl}
    //#presumption(void run()): getWeblogger(...).refererManager != null
    //#presumption(void run()): getWeblogger(...).refererManager.__Tag in {org/apache/roller/weblogger/business/jpa/JPARefererManagerImpl, org/apache/roller/weblogger/business/referrers/RefererManager}
    //#presumption(void run()): getWeblogger(...).threadManager != null
    //#presumption(void run()): getWeblogger(...).threadManager.__Tag in {org/apache/roller/weblogger/business/jpa/JPAThreadManagerImpl, org/apache/roller/weblogger/business/runnable/ThreadManager, org/apache/roller/weblogger/business/runnable/ThreadManagerImpl}
    //#presumption(void run()): getWeblogger(...).userManager != null
    //#presumption(void run()): getWeblogger(...).userManager.__Tag in {org/apache/roller/weblogger/business/UserManager, org/apache/roller/weblogger/business/jpa/JPAUserManagerImpl}
    //#presumption(void run()): getWeblogger(...).weblogManager != null
    //#presumption(void run()): getWeblogger(...).weblogManager.__Tag in {org/apache/roller/weblogger/business/WeblogManager, org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl}
    //#presumption(void run()): java.lang.System:currentTimeMillis(...)@102 - java.util.Date:getTime(...)@102 in -18_446_744_073_709_551_565..9_223_372_036_854_775_858
    //#presumption(void run()): java.lang.System:currentTimeMillis(...)@110 - java.util.Date:getTime(...)@110 in -18_446_744_073_709_551_565..9_223_372_036_854_775_858
    //#presumption(void run()): java.util.Calendar:getInstance(...)@79 != null
    //#presumption(void run()): org.apache.roller.util.DateUtil:getEndOfMinute(...)@101 != null
    //#presumption(void run()): org.apache.roller.util.DateUtil:getEndOfMinute(...)@109 != null
    //#presumption(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.__Tag@105 in {org/apache/roller/weblogger/business/GuiceWebloggerProvider, org/apache/roller/weblogger/business/WebloggerProvider}
    //#presumption(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.__Tag@112 in {org/apache/roller/weblogger/business/GuiceWebloggerProvider, org/apache/roller/weblogger/business/WebloggerProvider}
    //#presumption(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance@105 != null
    //#presumption(void run()): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance@112 != null
    //#presumption(void run()): org/apache/roller/weblogger/business/WebloggerImpl.log@105 != null
    //#presumption(void run()): org/apache/roller/weblogger/business/WebloggerImpl.log@112 != null
    //#unanalyzed(void run()): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(void run()): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(void run()): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(void run()): Effects-of-calling:org.apache.commons.logging.Log:debug
    //#unanalyzed(void run()): Effects-of-calling:getWeblogger
    //#unanalyzed(void run()): Effects-of-calling:getThreadManager
    //#unanalyzed(void run()): Effects-of-calling:java.util.List:iterator
    //#unanalyzed(void run()): Effects-of-calling:java.util.Iterator:hasNext
    //#unanalyzed(void run()): Effects-of-calling:java.util.Iterator:next
    //#unanalyzed(void run()): Effects-of-calling:getName
    //#unanalyzed(void run()): Effects-of-calling:getTaskLockByName
    //#unanalyzed(void run()): Effects-of-calling:org.apache.roller.weblogger.pojos.TaskLock:getName
    //#unanalyzed(void run()): Effects-of-calling:getInterval
    //#unanalyzed(void run()): Effects-of-calling:org.apache.roller.weblogger.pojos.TaskLock:getNextAllowedRun
    //#unanalyzed(void run()): Effects-of-calling:java.util.Date:getTime
    //#unanalyzed(void run()): Effects-of-calling:getStartTimeDesc
    //#unanalyzed(void run()): Effects-of-calling:java.lang.String:equals
    //#unanalyzed(void run()): Effects-of-calling:org.apache.roller.util.DateUtil:getStartOfDay
    //#unanalyzed(void run()): Effects-of-calling:org.apache.roller.util.DateUtil:getStartOfHour
    //#unanalyzed(void run()): Effects-of-calling:java.util.concurrent.ExecutorService:submit
    //#unanalyzed(void run()): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(void run()): Effects-of-calling:org.apache.commons.logging.Log:warn
    //#unanalyzed(void run()): Effects-of-calling:java.lang.ThreadLocal:get
    //#unanalyzed(void run()): Effects-of-calling:javax.persistence.EntityManagerFactory:createEntityManager
    //#unanalyzed(void run()): Effects-of-calling:java.lang.ThreadLocal:set
    //#unanalyzed(void run()): Effects-of-calling:javax.persistence.EntityManager:getTransaction
    //#unanalyzed(void run()): Effects-of-calling:javax.persistence.EntityTransaction:isActive
    //#unanalyzed(void run()): Effects-of-calling:javax.persistence.EntityTransaction:begin
    //#unanalyzed(void run()): Effects-of-calling:javax.persistence.EntityManager:createNamedQuery
    //#unanalyzed(void run()): Effects-of-calling:javax.persistence.Query:setParameter
    //#unanalyzed(void run()): Effects-of-calling:javax.persistence.Query:setFlushMode
    //#unanalyzed(void run()): Effects-of-calling:javax.persistence.Query:getSingleResult
    //#unanalyzed(void run()): Effects-of-calling:release
    //#unanalyzed(void run()): Effects-of-calling:javax.persistence.EntityTransaction:rollback
    //#unanalyzed(void run()): Effects-of-calling:javax.persistence.EntityManager:close
    //#unanalyzed(void run()): Effects-of-calling:org.apache.commons.logging.Log:error
    //#test_vector(void run()): java.lang.System:currentTimeMillis(...)@102 - java.util.Date:getTime(...)@102: {50..9_223_372_036_854_775_858}, {-18_446_744_073_709_551_565..49}
        
        // run forever, or until we get interrupted
        while(true) {
            try {
                // get current time
                Date now = new Date();
                log.debug("Current time = "+now);
    //#TaskScheduler.java:74: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void run()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
                
                // run tasks, skip run on first pass
                if(firstRun) {
                    // add a slight delay to scheduler start
                    Calendar cal = Calendar.getInstance();
                    cal.setTime(now);
                    cal.add(Calendar.MINUTE, 1);
                    cal.set(Calendar.SECOND, cal.getMinimum(Calendar.SECOND));
                    cal.set(Calendar.MILLISECOND, cal.getMinimum(Calendar.MILLISECOND));
                    now = cal.getTime();
                    log.debug("Start time = "+now);
    //#TaskScheduler.java:85: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void run()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
                    
                    firstRun = false;
                } else {
                    try {
                        runTasks(now);
    //#TaskScheduler.java:90: ?precondition failure
    //#    org/apache/roller/weblogger/business/runnable/TaskScheduler.runTasks: org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider != null
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void run()
    //#    basic block: bb_6
    //#    assertion: org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider != null
    //#    callee: void org/apache/roller/weblogger/business/runnable/TaskScheduler.runTasks(Date)
    //#    callee assertion: org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider != null
    //#    callee file: TaskScheduler.java
    //#    callee precondition index: [4]
    //#    callee srcpos: 131
    //#    VN: org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider
    //#    Expected: Inverse{null}
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad  Uncertain
                    } finally {
                        // always release session after each pass
                        WebloggerFactory.getWeblogger().release();
                    }
                }
                
                // wait 'til next minute
                // NOTE: we add 50ms of adjustment time to make sure we awaken
                //       during the next minute, and not before.  awakening at
                //       exactly the .000ms is not of any concern to us
                Date endOfMinute = DateUtil.getEndOfMinute(now);
    //#TaskScheduler.java:101: Warning: method not available
    //#    -- call on Date org.apache.roller.util.DateUtil:getEndOfMinute(Date)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void run()
    //#    unanalyzed callee: Date org.apache.roller.util.DateUtil:getEndOfMinute(Date)
                long sleepTime = (endOfMinute.getTime() + 50) - System.currentTimeMillis();
                if(sleepTime > 0) {
                    log.debug("sleeping - "+sleepTime);
    //#TaskScheduler.java:104: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void run()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
                    Thread.sleep(sleepTime);
                } else {
                    // it's taken us more than 1 minute for the last loop
                    // so recalculate to sleep 'til the end of the current minute
                    endOfMinute = DateUtil.getEndOfMinute(new Date());
    //#TaskScheduler.java:109: Warning: method not available
    //#    -- call on Date org.apache.roller.util.DateUtil:getEndOfMinute(Date)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void run()
    //#    unanalyzed callee: Date org.apache.roller.util.DateUtil:getEndOfMinute(Date)
                    sleepTime = (endOfMinute.getTime() + 50) - System.currentTimeMillis();
                    log.debug("sleeping - "+sleepTime);
    //#TaskScheduler.java:111: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void run()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
                    Thread.sleep(sleepTime);
                }
                
            } catch (InterruptedException ex) {
                // thread interrupted
                log.debug("Thread interrupted, scheduler is stopping");
    //#TaskScheduler.java:117: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void run()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
                pool.shutdownNow();
                break;
            }
        }
        
    }
    //#TaskScheduler.java:123: end of method: void org.apache.roller.weblogger.business.runnable.TaskScheduler.run()
    
    
    /**
     * Run the necessary tasks given a specific currentTime to work from.
     */
    private void runTasks(Date currentTime) {
        
        log.debug("Started - "+currentTime);
    //#TaskScheduler.java:131: method: void org.apache.roller.weblogger.business.runnable.TaskScheduler.runTasks(Date)
    //#TaskScheduler.java:131: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void runTasks(Date)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
    //#TaskScheduler.java:131: Warning: suspicious precondition
    //#    the precondition for org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.__Tag is not a contiguous range of values
    //#    severity: SUPPRESSED
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void runTasks(Date)
    //#    suspicious precondition index: [5]
    //#input(void runTasks(Date)): ": LAUNCHING task"._tainted
    //#input(void runTasks(Date)): ": Unhandled exception caught"._tainted
    //#input(void runTasks(Date)): ": next allowed run time = "._tainted
    //#input(void runTasks(Date)): "PingQueueTask"._tainted
    //#input(void runTasks(Date)): "ResetHitCountsTask"._tainted
    //#input(void runTasks(Date)): "SKIPPING task : "._tainted
    //#input(void runTasks(Date)): "ScheduledEntriesTask"._tainted
    //#input(void runTasks(Date)): "Started - "._tainted
    //#input(void runTasks(Date)): "TurnoverReferersTask"._tainted
    //#input(void runTasks(Date)): currentTime
    //#input(void runTasks(Date)): currentTime._tainted
    //#input(void runTasks(Date)): log
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/GuiceWebloggerProvider.__Dispatch_Table.getWeblogger()Lorg/apache/roller/weblogger/business/Weblogger;
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/Weblogger.__Descendant_Table[org/apache/roller/weblogger/business/WebloggerImpl]
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/Weblogger.__Descendant_Table[org/apache/roller/weblogger/business/Weblogger]
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/Weblogger.__Descendant_Table[org/apache/roller/weblogger/business/jpa/JPAWebloggerImpl]
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/Weblogger.__Descendant_Table[others]
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/Weblogger.__Dispatch_Table.getThreadManager()Lorg/apache/roller/weblogger/business/runnable/ThreadManager;
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.__Tag
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.__Tag
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.threadManager
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.threadManager.__Tag
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.threadManager.strategy
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.threadManager.strategy.__Tag
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.threadManager.strategy.emf
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance.threadManager.strategy.threadLocalEntityManager
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/WebloggerImpl.__Dispatch_Table.getThreadManager()Lorg/apache/roller/weblogger/business/runnable/ThreadManager;
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/WebloggerProvider.__Descendant_Table[org/apache/roller/weblogger/business/GuiceWebloggerProvider]
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/WebloggerProvider.__Descendant_Table[org/apache/roller/weblogger/business/WebloggerProvider]
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/WebloggerProvider.__Descendant_Table[others]
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/WebloggerProvider.__Dispatch_Table.getWeblogger()Lorg/apache/roller/weblogger/business/Weblogger;
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.__Descendant_Table[org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy]
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.__Descendant_Table[others]
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.__Dispatch_Table.getNamedQuery(Ljava/lang/String;)Ljavax/persistence/Query;
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.javax.persistence.FlushModeType.COMMIT
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/jpa/JPAThreadManagerImpl.__Dispatch_Table.getTaskLockByName(Ljava/lang/String;)Lorg/apache/roller/weblogger/pojos/TaskLock;
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/jpa/JPAWebloggerImpl.__Dispatch_Table.getThreadManager()Lorg/apache/roller/weblogger/business/runnable/ThreadManager;
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/pings/PingQueueTask.__Dispatch_Table.getInterval()I
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/pings/PingQueueTask.__Dispatch_Table.getName()Ljava/lang/String;
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/pings/PingQueueTask.__Dispatch_Table.getStartTimeDesc()Ljava/lang/String;
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/ResetHitCountsTask.__Dispatch_Table.getInterval()I
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/ResetHitCountsTask.__Dispatch_Table.getName()Ljava/lang/String;
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/ResetHitCountsTask.__Dispatch_Table.getStartTimeDesc()Ljava/lang/String;
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/RollerTask.__Descendant_Table[org/apache/roller/weblogger/business/pings/PingQueueTask]
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/RollerTask.__Descendant_Table[org/apache/roller/weblogger/business/runnable/ResetHitCountsTask]
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/RollerTask.__Descendant_Table[org/apache/roller/weblogger/business/runnable/RollerTaskWithLeasing]
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/RollerTask.__Descendant_Table[org/apache/roller/weblogger/business/runnable/RollerTask]
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/RollerTask.__Descendant_Table[org/apache/roller/weblogger/business/runnable/ScheduledEntriesTask]
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/RollerTask.__Descendant_Table[org/apache/roller/weblogger/business/runnable/TurnoverReferersTask]
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/RollerTask.__Descendant_Table[others]
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/RollerTask.__Dispatch_Table.getInterval()I
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/RollerTask.__Dispatch_Table.getName()Ljava/lang/String;
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/RollerTask.__Dispatch_Table.getStartTimeDesc()Ljava/lang/String;
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/RollerTaskWithLeasing.__Dispatch_Table.getInterval()I
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/RollerTaskWithLeasing.__Dispatch_Table.getName()Ljava/lang/String;
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/RollerTaskWithLeasing.__Dispatch_Table.getStartTimeDesc()Ljava/lang/String;
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/ScheduledEntriesTask.__Dispatch_Table.getInterval()I
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/ScheduledEntriesTask.__Dispatch_Table.getName()Ljava/lang/String;
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/ScheduledEntriesTask.__Dispatch_Table.getStartTimeDesc()Ljava/lang/String;
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/ThreadManager.__Descendant_Table[org/apache/roller/weblogger/business/jpa/JPAThreadManagerImpl]
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/ThreadManager.__Descendant_Table[org/apache/roller/weblogger/business/runnable/ThreadManagerImpl]
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/ThreadManager.__Descendant_Table[org/apache/roller/weblogger/business/runnable/ThreadManager]
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/ThreadManager.__Descendant_Table[others]
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/ThreadManager.__Dispatch_Table.getTaskLockByName(Ljava/lang/String;)Lorg/apache/roller/weblogger/pojos/TaskLock;
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/ThreadManagerImpl.__Dispatch_Table.getTaskLockByName(Ljava/lang/String;)Lorg/apache/roller/weblogger/pojos/TaskLock;
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/TurnoverReferersTask.__Dispatch_Table.getInterval()I
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/TurnoverReferersTask.__Dispatch_Table.getName()Ljava/lang/String;
    //#input(void runTasks(Date)): org/apache/roller/weblogger/business/runnable/TurnoverReferersTask.__Dispatch_Table.getStartTimeDesc()Ljava/lang/String;
    //#input(void runTasks(Date)): this
    //#input(void runTasks(Date)): this.pool
    //#input(void runTasks(Date)): this.tasks
    //#pre[3] (void runTasks(Date)): log != null
    //#pre[4] (void runTasks(Date)): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider != null
    //#pre[5] (void runTasks(Date)): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.__Tag in {org/apache/roller/weblogger/business/GuiceWebloggerProvider, org/apache/roller/weblogger/business/WebloggerProvider}
    //#pre[6] (void runTasks(Date)): org/apache/roller/weblogger/business/WebloggerFactory.webloggerProvider.webloggerInstance != null
    //#pre[9] (void runTasks(Date)): this.tasks != null
    //#pre[1] (void runTasks(Date)): (soft) currentTime != null
    //#pre[8] (void runTasks(Date)): (soft) this.pool != null
    //#presumption(void runTasks(Date)): getWeblogger(...).__Tag in {org/apache/roller/weblogger/business/Weblogger, org/apache/roller/weblogger/business/WebloggerImpl, org/apache/roller/weblogger/business/jpa/JPAWebloggerImpl}
    //#presumption(void runTasks(Date)): getWeblogger(...).threadManager != null
    //#presumption(void runTasks(Date)): java.util.Date:getTime(...)@180 - java.util.Date:getTime(...)@180 in -18_446_744_073_709_551_615..9_223_372_036_854_775_808
    //#presumption(void runTasks(Date)): java.util.Iterator:next(...).__Tag@135 in {org/apache/roller/weblogger/business/pings/PingQueueTask, org/apache/roller/weblogger/business/runnable/ResetHitCountsTask, org/apache/roller/weblogger/business/runnable/RollerTask, org/apache/roller/weblogger/business/runnable/RollerTaskWithLeasing, org/apache/roller/weblogger/business/runnable/ScheduledEntriesTask, org/apache/roller/weblogger/business/runnable/TurnoverReferersTask}
    //#presumption(void runTasks(Date)): java.util.Iterator:next(...)@135 != null
    //#presumption(void runTasks(Date)): org.apache.roller.util.DateUtil:getStartOfDay(...)@160 != null
    //#presumption(void runTasks(Date)): org.apache.roller.util.DateUtil:getStartOfHour(...)@168 != null
    //#presumption(void runTasks(Date)): org.apache.roller.weblogger.pojos.TaskLock:getNextAllowedRun(...)@148 != null
    //#presumption(void runTasks(Date)): tmgr.__Tag in {org/apache/roller/weblogger/business/jpa/JPAThreadManagerImpl, org/apache/roller/weblogger/business/runnable/ThreadManager, org/apache/roller/weblogger/business/runnable/ThreadManagerImpl}
    //#presumption(void runTasks(Date)): tmgr.strategy != null
    //#presumption(void runTasks(Date)): tmgr.strategy.__Tag == org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy
    //#presumption(void runTasks(Date)): tmgr.strategy.emf != null
    //#presumption(void runTasks(Date)): tmgr.strategy.threadLocalEntityManager != null
    //#unanalyzed(void runTasks(Date)): Effects-of-calling:getWeblogger
    //#unanalyzed(void runTasks(Date)): Effects-of-calling:java.lang.ThreadLocal:get
    //#unanalyzed(void runTasks(Date)): Effects-of-calling:javax.persistence.EntityManagerFactory:createEntityManager
    //#unanalyzed(void runTasks(Date)): Effects-of-calling:java.lang.ThreadLocal:set
    //#unanalyzed(void runTasks(Date)): Effects-of-calling:javax.persistence.EntityManager:getTransaction
    //#unanalyzed(void runTasks(Date)): Effects-of-calling:javax.persistence.EntityTransaction:isActive
    //#unanalyzed(void runTasks(Date)): Effects-of-calling:javax.persistence.EntityTransaction:begin
    //#unanalyzed(void runTasks(Date)): Effects-of-calling:javax.persistence.EntityManager:createNamedQuery
    //#unanalyzed(void runTasks(Date)): Effects-of-calling:javax.persistence.Query:setParameter
    //#unanalyzed(void runTasks(Date)): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(void runTasks(Date)): Effects-of-calling:javax.persistence.Query:setFlushMode
    //#unanalyzed(void runTasks(Date)): Effects-of-calling:javax.persistence.Query:getSingleResult
    //#test_vector(void runTasks(Date)): java.lang.String:equals(...)@157: {0}, {1}
    //#test_vector(void runTasks(Date)): java.lang.String:equals(...)@165: {0}, {1}
    //#test_vector(void runTasks(Date)): java.util.Date:getTime(...)@180 - java.util.Date:getTime(...)@180: {1..9_223_372_036_854_775_808}, {-18_446_744_073_709_551_615..0}
    //#test_vector(void runTasks(Date)): java.util.Iterator:hasNext(...)@135: {0}, {1}
        
        ThreadManager tmgr = WebloggerFactory.getWeblogger().getThreadManager();
        
        for( RollerTask task : tasks ) {
            try {
                // get tasklock for the task
                TaskLock tasklock = tmgr.getTaskLockByName(task.getName());
                
                // TODO: check if task is enabled, otherwise skip
                if(tasklock == null) {
                    log.debug("SKIPPING task : "+tasklock.getName());
    //#TaskScheduler.java:142: ?!null dereference
    //#    tasklock != null
    //#    severity: HIGH
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void runTasks(Date)
    //#    basic block: bb_5
    //#    assertion: tasklock != null
    //#    VN: getTaskLockByName(...)
    //#    Expected: Inverse{null} or Invalid
    //#    Bad: Addr_Set{null}
    //#    Attribs:  Ptr  null in Bad
    //#TaskScheduler.java:142: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.pojos.TaskLock:getName()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void runTasks(Date)
    //#    unanalyzed callee: String org.apache.roller.weblogger.pojos.TaskLock:getName()
    //#TaskScheduler.java:142: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void runTasks(Date)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
                    continue;
                }
                
                // first, calculate the next allowed run time for the task
                // based on when the task was last run
                Date nextRunTime = tasklock.getNextAllowedRun(task.getInterval());
    //#TaskScheduler.java:148: Warning: method not available
    //#    -- call on Date org.apache.roller.weblogger.pojos.TaskLock:getNextAllowedRun(int)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void runTasks(Date)
    //#    unanalyzed callee: Date org.apache.roller.weblogger.pojos.TaskLock:getNextAllowedRun(int)
                log.debug(task.getName()+": next allowed run time = "+nextRunTime);
    //#TaskScheduler.java:149: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void runTasks(Date)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
                
                // if we missed the last scheduled run time then see when the
                // most appropriate next run time should be and wait 'til then
                boolean needToWait = false;
                if(currentTime.getTime() > (nextRunTime.getTime() + ONE_MINUTE_MS)) {
                    
                    log.debug("MISSED last run, checking if waiting is necessary");
    //#TaskScheduler.java:156: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void runTasks(Date)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
                    if("startOfDay".equals(task.getStartTimeDesc())) {
                        // for daily tasks we only run during the first 
                        // couple minutes of the day
                        Date startOfDay = DateUtil.getStartOfDay(currentTime);
    //#TaskScheduler.java:160: Warning: method not available
    //#    -- call on Date org.apache.roller.util.DateUtil:getStartOfDay(Date)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void runTasks(Date)
    //#    unanalyzed callee: Date org.apache.roller.util.DateUtil:getStartOfDay(Date)
                        if(currentTime.getTime() > startOfDay.getTime() + (2 * ONE_MINUTE_MS)) {
                            needToWait = true;
                            log.debug("WAITING for next reasonable run time");
    //#TaskScheduler.java:163: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void runTasks(Date)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
                        }
                    } else if("startOfHour".equals(task.getStartTimeDesc())) {
                        // for hourly tasks we only run during the first
                        // couple minutes of the hour
                        Date startOfHour = DateUtil.getStartOfHour(currentTime);
    //#TaskScheduler.java:168: Warning: method not available
    //#    -- call on Date org.apache.roller.util.DateUtil:getStartOfHour(Date)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void runTasks(Date)
    //#    unanalyzed callee: Date org.apache.roller.util.DateUtil:getStartOfHour(Date)
                        if(currentTime.getTime() > startOfHour.getTime() + (2 * ONE_MINUTE_MS)) {
                            needToWait = true;
                            log.debug("WAITING for next reasonable run time");
    //#TaskScheduler.java:171: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void runTasks(Date)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
                        }
                    } else {
                        // for immediate tasks we just go ahead and run
                    }
                }
                
                // if we are within 1 minute of run time then execute,
                // otherwise we do nothing
                long differential = currentTime.getTime() - nextRunTime.getTime();
                if (differential >= 0 && !needToWait) {
                    log.debug(task.getName()+": LAUNCHING task");
    //#TaskScheduler.java:182: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void runTasks(Date)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
                    pool.submit(task);
                }
                
            } catch(Throwable t) {
                log.warn(task.getName()+": Unhandled exception caught", t);
    //#TaskScheduler.java:187: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:warn(Object, Throwable)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void runTasks(Date)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:warn(Object, Throwable)
            }
        }
        
        log.debug("Finished");
    //#TaskScheduler.java:191: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.business.runnable.TaskScheduler
    //#    method: void runTasks(Date)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
    }
    //#TaskScheduler.java:192: end of method: void org.apache.roller.weblogger.business.runnable.TaskScheduler.runTasks(Date)
    
}
    //#TaskScheduler.java:: end of class: org.apache.roller.weblogger.business.runnable.TaskScheduler
