java/code/src/com/redhat/rhn/taskomatic/task/ClearLogHistory.java | 18 ++++++----
1 file changed, 12 insertions(+), 6 deletions(-)
New commits:
commit 28c00123bf8e8f2f7ac66efb01d94f01074d6613
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Wed Sep 1 14:52:08 2010 +0200
fix ClearLogHistory
addressing NullPointerException
diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/ClearLogHistory.java b/java/code/src/com/redhat/rhn/taskomatic/task/ClearLogHistory.java
index de37e9c..be18672 100644
--- a/java/code/src/com/redhat/rhn/taskomatic/task/ClearLogHistory.java
+++ b/java/code/src/com/redhat/rhn/taskomatic/task/ClearLogHistory.java
@@ -43,12 +43,19 @@ public class ClearLogHistory extends RhnJavaJob {
throws JobExecutionException {
Integer days = null;
try {
- days = Integer.parseInt(
- (String) context.getJobDetail().getJobDataMap().get("days"));
- }
- catch (java.lang.ClassCastException cce) {
- throw new JobExecutionException("Invalid argument: days");
+ days = (Integer) context.getJobDetail().getJobDataMap().get("days");
+ } catch (java.lang.ClassCastException cce) {
+ String passedDays = (String) context.getJobDetail().getJobDataMap().get("days");
+ if (passedDays != null) {
+ try {
+ days = Integer.parseInt(passedDays);
+ }
+ catch (NumberFormatException nfe) {
+ throw new JobExecutionException("Invalid argument: days");
+ }
+ }
}
+
// if no value given, use default
if (days == null) {
days = DEFAULT_DAYS_VALUE;
@@ -75,7 +82,6 @@ public class ClearLogHistory extends RhnJavaJob {
// delete outdated schedules
List<TaskoSchedule> scheduleList = TaskoFactory.listSchedulesOlderThan(limitTime);
for (TaskoSchedule schedule : scheduleList) {
- Date endTime = schedule.getActiveTill();
if (TaskoFactory.listRunsBySchedule(schedule.getId()).isEmpty()) {
TaskoFactory.delete(schedule);
}