[TIMOB-12919] Avoid class cast exception

Test is in [JIRA](https://jira.appcelerator.org/browse/TIMOB-12919)