5

Some old code was obtaining information about record types by querying the RecordType object. But now that the RecordTypeInfo describe API includes the record type developer name, we have changed the logic to avoid that RecordType object query. The new code has been unit tested in a scratch org to make sure it doesn't use more CPU and it appears not to.

But two of our Continuous Integration builds - both of which have Shield Platform Encryption enabled - now have a business logic test where a lot of work is done failing with:

System.Exception: Apex CPU time limit exceeded

The new code is very simple:

SObjectType t = GD.get(objectTypeName);
if (t != null) {
    for (RecordTypeInfo info : t.getDescribe().getRecordTypeInfos()) {
        if (!info.isMaster()) {
            ...
        }
    }
}

Is this something anyone else has experienced? Any idea why? Is there is a work-around? (Present avoidance is to reduce the amount of work in the test when encryption is enabled.)

2

I'm sorry but it's unlikely that platform encryption is interfering in this particular piece of code.

Computing the record types is a non-trivial operation but it is orthogonal to platform encryption.

Maybe there is something else in your test that is CPU intensive, and maybe the extra CPU is indeed coming from encryption, but that would be I assume in another part of the Apex code.

  • Fair enough - thanks. What I observed was that the limit exception started happening in the CI builds right after the changes, and given that there are encryption related fields in the describe data there seemed to be a correlation. – Keith C Aug 28 '18 at 7:29

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.