6

Since the Spring '16 release I have noticed sporadic failures in some of our error handling code, specifically when we are adding a subclass of Exception to a collection of the base Exception class. I've seen the problem cause test case failures during validation runs as well as in the logs when debugging new code. It does not seem to be able to be reproduced with much reliability, although it occurs frequently enough that it's definitely noticeable.

System.TypeException: Collection store exception adding System.JSONException
    to List<java.lang.Exception>

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

I put together some simple test code to illustrate the issue; it throws one of these two exceptions seemingly at random. Based on the exception messages it seems that the Apex interpreter is confusing the standard Apex Exception class with the underlying java.lang.Exception class:

public class TestException extends Exception {
}

List<Exception> exceptions = new List<Exception>();
try {
    throw new TestException('testing...');
} catch ( Exception e ) {
    exceptions.add(e);              // this line throws System.TypeException
}

for ( Exception e : exceptions ) {  // this line throws System.QueryException
    System.debug('test...' + e.getMessage());
}

Interestingly enough I also notice the following entries in the debug logs, which I've never seen prior to the Spring '16 release. It may be unrelated but I thought it might be worth noting.

17:11:44.140 (171155397)|ENTERING_MANAGED_PKG|java__util
17:11:44.140 (171222643)|ENTERING_MANAGED_PKG|java__util
17:11:44.140 (171283094)|ENTERING_MANAGED_PKG|java__util
17:11:44.140 (171350089)|ENTERING_MANAGED_PKG|java__util
17:11:44.140 (171441563)|ENTERING_MANAGED_PKG|java__util
17:11:44.140 (171475377)|ENTERING_MANAGED_PKG|java__util
17:11:44.140 (171526442)|ENTERING_MANAGED_PKG|java__util
17:11:44.140 (171572843)|ENTERING_MANAGED_PKG|java__util
17:11:44.140 (171590960)|ENTERING_MANAGED_PKG|java__util
17:11:44.140 (171660695)|ENTERING_MANAGED_PKG|java__util
17:11:44.140 (171701086)|ENTERING_MANAGED_PKG|java__util
17:11:44.140 (171758005)|ENTERING_MANAGED_PKG|java__util
17:11:44.140 (171775025)|ENTERING_MANAGED_PKG|java__util
17:11:44.140 (171828188)|ENTERING_MANAGED_PKG|java__util
17:11:44.140 (171869816)|ENTERING_MANAGED_PKG|java__util
17:11:44.140 (171913392)|ENTERING_MANAGED_PKG|java__util
17:11:44.140 (171957590)|ENTERING_MANAGED_PKG|java__util
17:11:44.140 (172029379)|ENTERING_MANAGED_PKG|java__util
17:11:44.140 (172078779)|ENTERING_MANAGED_PKG|java__util
17:11:44.140 (172131169)|ENTERING_MANAGED_PKG|java__util

Is anyone else noticing either of these errors on seemingly valid code?

Update 2/19/16: I opened a case with Salesforce and they directed me to a newly-created Known Issue: Collection store exception thrown when adding an Exception to a apex collection. There is currently no ETA for when this will be resolved.

2

I started encountering this since the release of Spring '16.

enter image description here

Weird #Salesforce Apex TypeException where an inner class that extends Exception can't go into a Map of <,Exception> Source

The intermittent nature makes it hard to track down. Trying to create a managed package is a bit of a role of the dice.

There is now a known issue for it - Collection store exception thrown when adding an Exception to a apex collection that is currently scheduled for the Spring '16 Patch 11.0 release.

  • 1
    I see you had identified the known issue in your question as well. Looks like it shouldn't be too far off. Most orgs are on Patch 9.5 or 9.6 currently. Most of the items in 10.0 where scheduled in the last 2 days. and 9.0 3 days ago. I'd tentatively expect it within a few days. – Daniel Ballinger Feb 21 '16 at 23:55
  • Fingers crossed! – JCD Feb 23 '16 at 14:31
  • This should be fixed now, with SPRING '16 PATCH 11.0 being released. – Daniel Ballinger Mar 8 '16 at 21:07
0

I've seen people discuss this error occasionally on Twitter since the Spring '16 release.

All you can really do is open a case with as much information as possible and have it escalated to T3 / R&D.

Not much of a solution I'm afraid but it's not uncommon to see problems like this after a release.

  • Yep, I opened a case. R&D is aware of the problem but there's no ETA for resolution. – JCD Feb 19 '16 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.