Commits

timemachine committed 058e755

Added try/catch to protect the DateListSchedule provider code.

Comments (0)

Files changed (2)

timemachine-scheduler/src/main/java/timemachine/scheduler/schedule/DateListSchedule.java

 	}
 	
 	private List<Date> generateNextDateList(DateListSchedule schedule) {
-		if (dateListProviderClassName == null)
-			return new ArrayList<Date>();
-		
-		logger.debug("Generating new date list using {}", dateListProviderClassName);
-		Class<DateListProvider> cls = Utils.toClass(dateListProviderClassName);
-		DateListProvider dateListProvider = Utils.newInstance(cls);
-		List<Date> result = dateListProvider.getDateList(schedule);
-		logger.debug("Generated {} dates", result.size());
+		List<Date> result = new ArrayList<Date>();
+		if (dateListProviderClassName != null) {
+			try {
+				logger.debug("Generating new date list using {}", dateListProviderClassName);
+				Class<DateListProvider> cls = Utils.toClass(dateListProviderClassName);
+				DateListProvider dateListProvider = Utils.newInstance(cls);
+				result = dateListProvider.getDateList(schedule);
+				logger.debug("Generated {} dates", result.size());
+			} catch (RuntimeException e) {
+				logger.error("Failed to generate new date list by provider " + dateListProviderClassName, e);
+			}
+		}
 		return result;
 	}
 

timemachine-scheduler/src/main/java/timemachine/scheduler/schedule/EndOfMonthDateListProvider.java

 import timemachine.scheduler.schedule.DateListSchedule.DateListProvider;
 
 /**
- * A provider that always returns the end of month date from prevRunDate. If prevRunDate is null, then end of 
+ * A date list provider that always returns the end of month date from prevRunDate. If prevRunDate is null, then end of 
  * current month.
  * @author Zemian Deng
  */