incubator-ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ange...@apache.org
Subject svn commit: r1073698 - in /incubator/ace/trunk/ace-scheduler/src: main/java/org/apache/ace/scheduler/Scheduler.java test/java/org/apache/ace/scheduler/SchedulerTest.java
Date Wed, 23 Feb 2011 11:02:52 GMT
Author: angelos
Date: Wed Feb 23 11:02:52 2011
New Revision: 1073698

URL: http://svn.apache.org/viewvc?rev=1073698&view=rev
Log:
ACE-128 The scheduler now ignores unparsable properties.

Modified:
    incubator/ace/trunk/ace-scheduler/src/main/java/org/apache/ace/scheduler/Scheduler.java
    incubator/ace/trunk/ace-scheduler/src/test/java/org/apache/ace/scheduler/SchedulerTest.java

Modified: incubator/ace/trunk/ace-scheduler/src/main/java/org/apache/ace/scheduler/Scheduler.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-scheduler/src/main/java/org/apache/ace/scheduler/Scheduler.java?rev=1073698&r1=1073697&r2=1073698&view=diff
==============================================================================
--- incubator/ace/trunk/ace-scheduler/src/main/java/org/apache/ace/scheduler/Scheduler.java
(original)
+++ incubator/ace/trunk/ace-scheduler/src/main/java/org/apache/ace/scheduler/Scheduler.java
Wed Feb 23 11:02:52 2011
@@ -27,6 +27,7 @@ import java.util.Map;
 import org.osgi.framework.Constants;
 import org.osgi.service.cm.ConfigurationException;
 import org.osgi.service.cm.ManagedService;
+import org.osgi.service.log.LogService;
 
 /**
  * The scheduler periodically runs tasks based on a scheduling recipe. Tasks can be added
and
@@ -39,6 +40,7 @@ import org.osgi.service.cm.ManagedServic
  */
 public class Scheduler implements ManagedService {
     protected Map m_tasks = new HashMap/*<String, SchedulerTask>*/();
+    private volatile LogService m_log;
 
     /**
      * Makes sure that all tasks are indeed stopped when the scheduler is stopped.
@@ -116,7 +118,15 @@ public class Scheduler implements Manage
                     schedTask = new SchedulerTask(name);
                     m_tasks.put(name, schedTask);
                 }
-                schedTask.updateConfigurationRecipe(properties.get(name));
+                try {
+                    schedTask.updateConfigurationRecipe(properties.get(name));
+                }
+                catch (ConfigurationException ce) {
+                    // This is most likely an illegal recipe, caused by an config property
we don't understand.
+                    // So, no problem.
+                    m_log.log(LogService.LOG_INFO,
+                            name + "=" + properties.get(name) + " does not look like a valid
schedule recipe.");
+                }
             }
 
             // and remove all tasks that now have no schedule or runnable
@@ -124,7 +134,7 @@ public class Scheduler implements Manage
                 String name = (String) i.next();
                 SchedulerTask schedTask = (SchedulerTask) m_tasks.get(name);
                 if (!schedTask.process()) {
-                    m_tasks.remove(name);
+                    i.remove();
                 }
             }
         }

Modified: incubator/ace/trunk/ace-scheduler/src/test/java/org/apache/ace/scheduler/SchedulerTest.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-scheduler/src/test/java/org/apache/ace/scheduler/SchedulerTest.java?rev=1073698&r1=1073697&r2=1073698&view=diff
==============================================================================
--- incubator/ace/trunk/ace-scheduler/src/test/java/org/apache/ace/scheduler/SchedulerTest.java
(original)
+++ incubator/ace/trunk/ace-scheduler/src/test/java/org/apache/ace/scheduler/SchedulerTest.java
Wed Feb 23 11:02:52 2011
@@ -59,14 +59,15 @@ public class SchedulerTest {
         assert !((SchedulerTask) m_scheduler.m_tasks.get("local.mock.task1")).isScheduled()
: "Since we have not provided a runnable for the scheduler, the tasks should not be scheduled.";
     }
 
-    @Test(groups = { UNIT }, expectedExceptions = ConfigurationException.class)
-    public synchronized void testIllegalUpdate() throws Exception {
+    @Test( groups = { UNIT } )
+    public synchronized void testAdditionalProperties() throws Exception {
         Properties props = new Properties();
         props.put("local.mock.task1", "invalidValue");
         m_scheduler.updated(props);
         m_scheduler.addRunnable("local.mock.task1", new Runnable() {
             public void run() {
             }}, "Dummy testing task", null, false);
+        // We should be able to get here, since unrecognized properties should be ignored.
     }
 
     @Test(groups = { UNIT })



Mime
View raw message