LPS-45936 Companies stored in a non default shard are not initialized properly on startup

Hi @shuyangzhou,

The method com.liferay.portal.dao.shard.advice.ShardPersistenceAdvice uses the variable companyId from CompanyThreadLocal.getCompanyId to know the company we are currently in (shardAdvice.setShardNameByCompany()). But during the logic of CompanyThreadLocal.setCompanyId(companyId) that variable hasn't been initialized yet and the previous exception is displayed (see LPS-45936 for more information)

This causes that companies belong to non default shards aren't initialized properly (method com.liferay.portal.util.PortalInstances._initCompany)

Thanks.

PD: @migue