Uploaded image for project: 'OpenOLAT'
  1. OpenOLAT
  2. OO-2281

Sending of reminders stops with NPE

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 11.0.6
    • Fix Version/s: 11.0.8
    • Component/s: None
    • Labels:
      None

      Description

      In o_as_entry it's possible that a_score does not contain a value. If a course reminder rule tests for an empty score, a NPE occurs:

      2016-10-14 09:00:08,734 [schedulerFactoryBean_Worker-5] ERROR JobRunShell  - Job DEFAULT.reminderJobDetail threw an unhandled Exception: 
      java.lang.NullPointerException
      	at org.olat.course.reminder.manager.ReminderRuleDAO.getScores(ReminderRuleDAO.java:81)
      	at org.olat.course.reminder.rule.ScoreRuleSPI.filter(ScoreRuleSPI.java:115)
      	at org.olat.modules.reminder.manager.ReminderRuleEngine.filterByRules(ReminderRuleEngine.java:245)
      	at org.olat.modules.reminder.manager.ReminderRuleEngine.evaluate(ReminderRuleEngine.java:98)
      	at org.olat.modules.reminder.manager.ReminderServiceImpl.sendReminder(ReminderServiceImpl.java:234)
      	at org.olat.modules.reminder.manager.ReminderServiceImpl.remindAll(ReminderServiceImpl.java:228)
      	at org.olat.modules.reminder.manager.ReminderJob.executeWithDB(ReminderJob.java:43)
      	at org.olat.core.commons.services.scheduler.JobWithDB.executeInternal(JobWithDB.java:59)
      	at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:114)
      	at org.quartz.core.JobRunShell.run(JobRunShell.java:223)
      	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
      

      This patch fixes that:

      diff --git a/src/main/java/org/olat/course/reminder/manager/ReminderRuleDAO.java b/src/main/java/org/olat/course/reminder/manager/ReminderRuleDAO.java
      --- a/src/main/java/org/olat/course/reminder/manager/ReminderRuleDAO.java
      +++ b/src/main/java/org/olat/course/reminder/manager/ReminderRuleDAO.java
      @@ -31,7 +31,10 @@
       import org.olat.core.commons.persistence.DB;
       import org.olat.core.commons.persistence.PersistenceHelper;
       import org.olat.core.id.Identity;
      +import org.olat.core.logging.OLog;
      +import org.olat.core.logging.Tracing;
       import org.olat.course.nodes.CourseNode;
      +import org.olat.course.reminder.rule.ScoreRuleSPI;
       import org.olat.repository.RepositoryEntryRef;
       import org.springframework.beans.factory.annotation.Autowired;
       import org.springframework.stereotype.Service;
      @@ -48,6 +51,7 @@
       	@Autowired
       	private DB dbInstance;
       
      +	private static final OLog log = Tracing.createLoggerFor(ScoreRuleSPI.class);
       
       	public Map<Long,Float> getScores(RepositoryEntryRef entry, CourseNode node, List<Identity> identities) {
       		if(identities == null || identities.isEmpty()) {
      @@ -76,9 +80,13 @@
       		Map<Long,Float> dateMap = new HashMap<>();
       		for(Object[] infos:infoList) {
       			Long identityKey = (Long)infos[0];
      -			if(identityKeySet == null || identityKeySet.contains(identityKey)) {
      -				Number score = (Number)infos[1];
      -				dateMap.put(identityKey, score.floatValue());
      +			try {
      +				if(identityKeySet == null || identityKeySet.contains(identityKey)) {
      +					Number score = (Number)infos[1];
      +					dateMap.put(identityKey, score.floatValue());
      +				}
      +			} catch (Exception e) {
      +				log.error("Error getting score: Course "+entry.getKey()+", Node "+node.getIdent()+", Identity "+identityKey+", Score "+infos[1]);
       			}
       		}
       		return dateMap;
      

        Attachments

          Activity

            People

            Assignee:
            srosse Stéphane Rossé
            Reporter:
            stephan Stephan Clemenz
            Tester:
            Florian Gnägi
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 35 minutes
                35m