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

5
  • 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, 2019 at 13:49
  • 2
    @ca_peterson You might be interested in taking a look at this.
    – sfdcfox
    Feb 12, 2019 at 14:36
  • 3
    Bug filed as W-5851163. Thanks for the great repro case. Feb 13, 2019 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. Feb 13, 2019 at 3:12
  • You're welcome. I had hoped I might have done something I could correct. But well, workaround exists for now. Feb 13, 2019 at 11:43

1 Answer 1

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

You must log in to answer this question.

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