2

I am tried calling below @AuraEnabled method from a lightning component.

    @AuraEnabled
public static ConnectApi.FeedElementPage getFeedElementsOfType(String feedType, Integer pageSize, String pageToken, String sortParam,String subjectId) {

    feedType = feedType != null
        ? feedType
        : 'UserProfile';
    pageSize = pageSize != null
        ? pageSize
        : 10;

    pageToken = String.isNotBlank(pageToken)
        ? pageToken
        : null;
    sortParam =  String.isNotBlank(sortParam)
        ? sortParam
        : null;
    subjectId = subjectId != null
        ? subjectId
        : 'me';
    return ChatterUtils.getFeedElements(feedType, subjectId, pageSize, pageToken, sortParam);
}

This was giving me error as below in callback function of lightning component helper method.

An internal server error has occurred Error ID: 1483360533-7490 (1005877919)

org.auraframework.throwable.AuraExecutionException: apex://ChatterFeedController: java.lang.IllegalArgumentException: java.lang.ClassCastException@7c7b83dc

But same code was running fine if I replace

    pageSize = pageSize != null
    ? pageSize
    : 10;

with

    pageSize = pageSize != null
    ? Integer.valueOf(pageSize)
    : 10;

This seems to be a strange issue. Does anyone have any idea about this behavior ?

2
  • Is there any static variables, called pageSize with type of string? Or parent class property?
    – kurunve
    Commented Apr 13, 2017 at 8:52
  • @kurunve : No, I don't have any static variable named pageSize. Its a local variable( method parameter). Commented Apr 13, 2017 at 9:40

1 Answer 1

3

This is a bug in the Framework. I've created a Case for that, and the answer was that it was already tracked but not fixed yet. The workaround is to do what you did, casting again to an Integer.

There are several issues like this currently in the framework, I've published a blog post to try to list them and their related workaround, you can have a look here if you're interested.

I would suggest that you also create a Case on Salesforce side for that. The more Cases related to this issue, the more likely they are to fix it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .