Salesforce Exception Collections Internal Error

We had some legacy code which was storing exceptions happening during future methods into Salesforce custom object.
This tool had some code which was converting a single exception into a list and then iteration over the list was performed.

This issue could be reproduced by the following snippet:

try {
String testString;
Boolean testBool = testString.startsWith( 'text' );
} catch ( Exception e ) {
for ( System.Exception anExToLog : new List{ e } ) {
System.debug(LoggingLevel.ERROR, '@@@ anExToLog: ' + anExToLog );
}
}

When we tried to execute this code, the following exception was raised:

System.QueryException: Dynamic query yields incompatible SObject type System.NullPointerException for loop variable of type java.lang.Exception

We have opened a ticket against Salesforce support on 9th of February.

Finally today, in about two weeks, Salesforce has acknowledged this as an issue and provided a link for us to click “This issue affects me” to get email alert when the issue is fixed. If this issue affects you then you can also subscribe to it.

If you notice some other internal error issue then you can also open Salesforce support ticket by following the link being logged in to Salesforce. You may find the open cases by this link and your closed cases by this link.

2 replies
  1. Ac
    Ac says:

    Were you able to fix this issue? I’m also having this error on the test class of a scheduler class wherein on the finish method we are inserting a record if there’s an exception. Calling the finish method causes a null pointer with the same issue you encountered.
    Do you have solution for this?

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *