8

I have a weird issue, can somebody help?

On API 45, the following test crashes with

FATAL_ERROR System.UnexpectedException: java.lang.String cannot be cast to apex.bytecodeinterpreter.ObjectInstance

on set2.retainAll (set1).

If I save the same class as API 44, all is well, and Set.retainAll () works as expected.

@isTest
public class UnexpectedTest {

    @isTest
    public static void testSet () {
        Set<Id> set1 = new Set<id> {'0MI4E0000000NrOWAU', '0MI4E0000000NrNWAU'};
        Set<Id> set2 = new Set<id> {'0MI4E0000000NrNWAU', '0MI4E0000000NrOWAU'};

        set2.retainAll (set1);
        System.debug (set2);
    }
}

This happens on all orgs I have access to.

Update 2019-04-01: I have just tried it again, and it seems to work now with API 45

  • If you have confirmed this is API 45.0 issue, then you would need to contact Support to verify if this is an issue with the Spring release. – Jayant Das Feb 12 at 13:49
  • 2
    @ca_peterson You might be interested in taking a look at this. – sfdcfox Feb 12 at 14:36
  • 3
    Bug filed as W-5851163. Thanks for the great repro case. – ca_peterson Feb 13 at 1:47
  • 3
    Also heads up that sfse mentions don't alert me - generally better to tweet at me if you want to flag me down for comments on a specific question. – ca_peterson Feb 13 at 3:12
  • You're welcome. I had hoped I might have done something I could correct. But well, workaround exists for now. – Florian Heer Feb 13 at 11:43
6

This is almost certainly related to the known issue The result of Set.retainAll(Set) are inconsistent between ApexCode log level is FINEST and it is FINER(or lower) being resolved in Spring '19.

It's specifically tied to the current logging level.

In my Dev Org, which is currently on Spring '19 Patch 8.7 your sample test class fails with the message:

System.UnexpectedException: java.lang.String cannot be cast to apex.bytecodeinterpreter.ObjectInstance

But, only if the ApexCode logging level is set to FINEST. If I dial it back to FINER the test passes just fine.

Or it might be The result of List.contains() are inconsistent between ApexCode log level is FINEST and it is FINER(or lower). I don't have any inside information on this, but I think it is safe to say they are probably related.


Update from twitter, sounds like they are onto it now.

Bug filed as W-5851163

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.