Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25888] Android: getEventsBetweenDates() crashes

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2018-04-20T21:42:51.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.3.0
ComponentsAndroid
Labelsregression
ReporterMichiel van Eerd
AssigneeYordan Banev
Created2018-03-20T08:47:26.000+0000
Updated2018-06-22T16:33:25.000+0000

Description

On Android 8 with Titanium 7.1.0.GA the app crahses when calling getEventsBetweenDates(). With SDK 7.0.2.GA everything is okay. This is the log I see after calling getEventsBetweenDates():
[WARN]  W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String[] java.lang.String.split(java.lang.String)' on a null object reference
[WARN]  W/System.err: 	at ti.modules.titanium.calendar.RecurrenceRuleProxy.fillFrequencyFields(RecurrenceRuleProxy.java:233)
[WARN]  W/System.err: 	at ti.modules.titanium.calendar.RecurrenceRuleProxy.<init>(RecurrenceRuleProxy.java:189)
[WARN]  W/System.err: 	at ti.modules.titanium.calendar.EventProxy.setRecurrenceRules(EventProxy.java:499)
[WARN]  W/System.err: 	at ti.modules.titanium.calendar.EventProxy.queryEventsBetweenDates(EventProxy.java:133)
[WARN]  W/System.err: 	at ti.modules.titanium.calendar.EventProxy.queryEventsBetweenDates(EventProxy.java:272)
[WARN]  W/System.err: 	at ti.modules.titanium.calendar.CalendarProxy.getEventsBetweenDates(CalendarProxy.java:187)
[WARN]  W/System.err: 	at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
[WARN]  W/System.err: 	at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:63)
[WARN]  W/System.err: 	at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:962)
[WARN]  W/System.err: 	at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1186)
[WARN]  W/System.err: 	at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:394)
[WARN]  W/System.err: 	at ti.modules.titanium.ui.PickerProxy.handleMessage(PickerProxy.java:351)
[WARN]  W/System.err: 	at android.os.Handler.dispatchMessage(Handler.java:101)
[WARN]  W/System.err: 	at android.os.Looper.loop(Looper.java:164)
[WARN]  W/System.err: 	at android.app.ActivityThread.main(ActivityThread.java:6541)
[WARN]  W/System.err: 	at java.lang.reflect.Method.invoke(Native Method)
[WARN]  W/System.err: 	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
[WARN]  W/System.err: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

Comments

  1. Mostafizur Rahman 2018-03-20

    Hello [~michielve], Thanks for sharing with us. Please create a full reproducible test code and provide here for us to test the issue. Also, provide detail affected environment. Thanks.
  2. Michiel van Eerd 2018-03-20

    No problem - *I see that this bug only happens with events that are repeated weekly*!.
       var calendarName = "Name of calendar that has weekly repeated events";
       
       function doClick(e) {
       	if (!Ti.Calendar.hasCalendarPermissions()) {
       		Ti.Calendar.requestCalendarPermissions(function(args) {
       			if (args.success) {
       				showCalendars();
       			}
       		});
       	} else {
       		showCalendars();
       	}
       }
       
       function showCalendars() {
       	console.log("In showCalendars");
       	var calendars = Ti.Calendar.allCalendars;
       	for (var i = 0; i < calendars.length; i++) {
       		var cal = calendars[i];
       		if (cal.name === calendarName) {
       			console.log("Try to show weekly events from calendar " + calendarName);
       			var now = new Date();
       			try {
       				var events = cal.getEventsBetweenDates(new Date(now.getFullYear() - 1, now.getMonth(), now.getDate()), now);
       				console.log("I have " + events.length + " events");
       				events.forEach(function(event) {
       					console.log("Event " + event.title);
       				});
       			} catch (ex) {
       				console.error(ex);
       			}
       			return;
       		}
       	}
       }
       
  3. Yordan Banev 2018-03-20

    Thank you! I was able to reproduce the issue.
  4. Yordan Banev 2018-03-20

    PR: https://github.com/appcelerator/titanium_mobile/pull/9949
  5. Lokesh Choudhary 2018-04-20

    FR Passed. PR Merged.
  6. Lokesh Choudhary 2018-06-22

    Verified the fix in SDK 7.3.0.v20180618182516. Closing.

JSON Source