Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-7880

Avoid NPE when adapting to Tenant for a system users

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Tenant 1.1.0
    • Fix Version/s: Tenant 1.1.2
    • Component/s: Extensions
    • Labels:
      None

      Description

      when trying to adapt a Resource to a tenant:

          Tenant tenant = resourceResolver.adaptTo(Tenant.class);
      

      this can lead to a NPE in the TenantAdapterFactory which is catched and logged:

      02.09.2018 11:14:27.586 *ERROR* [0:0:0:0:0:0:0:1 [1535879667510] GET /content/alpha64Project/en.html HTTP/1.1] org.apache.sling.tenant.internal.TenantAdapterFactory can not get user from session
      java.lang.NullPointerException: null
      	at org.apache.sling.tenant.internal.TenantAdapterFactory.getAdapter(TenantAdapterFactory.java:122)
      	at org.apache.sling.tenant.internal.TenantAdapterFactory.getAdapter(TenantAdapterFactory.java:101)
      	at org.apache.sling.adapter.internal.AdapterManagerImpl.getAdapter(AdapterManagerImpl.java:143)
      	at org.apache.sling.api.adapter.SlingAdaptable.adaptTo(SlingAdaptable.java:104)
      	at org.apache.sling.resourceresolver.impl.ResourceResolverImpl.adaptTo(ResourceResolverImpl.java:818)
      ...
      

      when the user of the resource resolver is a system user, and this user has no special access privileges to it's own home path.

        Attachments

          Activity

            People

            • Assignee:
              sseifert Stefan Seifert
              Reporter:
              sseifert Stefan Seifert
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: