Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-108590

Always set the CompanyThreadLocal when iterating through companies (create a SF rule to avoid issues in the future)

    Details

    • Branch Version/s:
      7.3.x
    • Backported to Branch:
      Committed
    • Sprint:
      Upgrade|19.10-2.11|BolloPre├▒ao, Upgrade|5.11-23.11|BoqueronesV, Upgrade|23.11-7.12|Bravas, Upgrade|14.12-28.12|Callos, Upgrade|4.1-18.1|CarneEnSarsa, Upgrade|1.18-2.1|Caz├│nEnAdobo, Upgrade|2.1-2.15|Ensaladilla, Upgrade|2.17-3.3|Espeto, Upgrade|3.3-3.17|Gallinejas, Upgrade|3.17-3.31|Gazpacho

      Description

      Anytime run over companies like in:

      ActionableDynamicQuery actionableDynamicQuery =
      	companyLocalService.getActionableDynamicQuery();
      
      actionableDynamicQuery.setPerformActionMethod(
      	(Company company) -> {
      		try {
      			method()
      		}
      		catch (Exception exception) {
      			throw new SystemException(exception);
      		}
      	});
      
      actionableDynamicQuery.performActions();
      

      or in

      for (Company company : companies) {
      	method()
      }
      

      And we call services in the logic, we should set the companyThreadLocal so we use the proper partition.

      Fortunately, there are not so many cases like these since:

      • These calls can be done only in global places. It doesn't make sense to do this in the logic related to one single company.
      • We already set the CompanyThreadLocal in cases like these when we modify objects since we take the companyId in the service/persistence implementation from the CompanyThreadLocal

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              kyle.miho Kyle Miho
              Reporter:
              alberto.chaparro Alberto Chaparro
              Engineering Assignee:
              Alberto Chaparro
              Recent user:
              Rafaela Nascimento
              Participants of an Issue:
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Packages

                  Version Package
                  7.3.X
                  7.4.0 CE GA1
                  Master