Skip to content

Commit

Permalink
Ignore recurrence if start and due are absent, fixes #841 (#844)
Browse files Browse the repository at this point in the history
Apparently there are tasks which have a recurrence rule but neither a dtstart nor a due date. This caused an NPE. By treating such tasks as non-recurring this should be fixed.
  • Loading branch information
dmfs authored Sep 14, 2019
1 parent 81f5b5a commit d0fd159
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.dmfs.opentaskspal.tasklists.NameData;
import org.dmfs.opentaskspal.tasks.OriginalInstanceData;
import org.dmfs.opentaskspal.tasks.OriginalInstanceSyncIdData;
import org.dmfs.opentaskspal.tasks.RRuleTaskData;
import org.dmfs.opentaskspal.tasks.StatusData;
import org.dmfs.opentaskspal.tasks.SyncIdData;
import org.dmfs.opentaskspal.tasks.TimeData;
Expand All @@ -61,6 +62,8 @@
import org.dmfs.opentaskstestpal.InstanceTestData;
import org.dmfs.rfc5545.DateTime;
import org.dmfs.rfc5545.Duration;
import org.dmfs.rfc5545.recur.InvalidRecurrenceRuleException;
import org.dmfs.rfc5545.recur.RecurrenceRule;
import org.dmfs.tasks.contract.TaskContract.Instances;
import org.dmfs.tasks.contract.TaskContract.TaskLists;
import org.dmfs.tasks.contract.TaskContract.Tasks;
Expand Down Expand Up @@ -904,4 +907,39 @@ public void testMoveTaskInstanceAsSyncAdapter() throws Exception
));
}


/**
* Create task with start and due, check datetime values including generated duration.
*/
@Test
public void testInsertTaskWithoutStartAndDueButRRULE() throws InvalidRecurrenceRuleException
{
RowSnapshot<TaskLists> taskList = new VirtualRowSnapshot<>(new LocalTaskListsTable(mAuthority));
RowSnapshot<Tasks> task = new VirtualRowSnapshot<>(new TaskListScoped(taskList, new TasksTable(mAuthority)));

DateTime start = DateTime.now();
DateTime due = start.addDuration(new Duration(1, 1, 0));

assertThat(new Seq<>(
new Put<>(taskList, new EmptyRowData<>()),
new Put<>(task, new Composite<>(
new TitleData("test"),
new RRuleTaskData(new RecurrenceRule("FREQ=DAILY;COUNT=5", RecurrenceRule.RfcMode.RFC2445_LAX))))),
resultsIn(mClient,
new Assert<>(task, new Composite<>(
new TitleData("test"),
new VersionData(0))),
new AssertRelated<>(
new InstanceTable(mAuthority), Instances.TASK_ID, task,
new Composite<>(
new CharSequenceRowData<>(Tasks.TITLE, "test"),
new InstanceTestData(
absent(),
absent(),
absent(),
0),
new CharSequenceRowData<>(Tasks.TZ, null))
)));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public Uri uri(String authority)
@Override
public boolean isRecurring()
{
return valueOf(RRULE) != null || valueOf(RDATE).iterator().hasNext();
// recurring tasks must have an RRULE or RDATEs and at least one of DTSTART and DUE date
return (valueOf(RRULE) != null || valueOf(RDATE).iterator().hasNext()) && (valueOf(DTSTART) != null || valueOf(DUE) != null);
}


Expand Down

0 comments on commit d0fd159

Please sign in to comment.