Uploaded image for project: 'OpenAM'
  1. OpenAM
  2. OPENAM-17523

SmsResourceProvider throws NPE



    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 6.5.3
    • None
    • rest, REST-SMS


      Bug description

      SmsResourceProvider throws NPE

      How to reproduce the issue

      This seems to be a timing issue, but you can recreate the issue by running

      temper shell-tests --only-classes ImportExportTest

      The test fails with response code 500 Internal Error and debug log shows the following exception:

      frRest:03/08/2021 03:38:34:621 PM NZDT: Thread[http-nio-18080-exec-3,5,main]: TransactionId[546b03c9-4677-4329-b87c-21a9e61f151d-42206]
      ERROR: A runtime exception occurred during the CREST request handling
      java.lang.IllegalStateException: Exception from invocation expected to be handled by promise
              at org.forgerock.json.resource.AnnotatedMethod.invoke(AnnotatedMethod.java:100)
      Caused by: java.lang.reflect.InvocationTargetException
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:498)
              at org.forgerock.json.resource.AnnotatedMethod.invoke(AnnotatedMethod.java:96)
              ... 149 more
      Caused by: java.lang.NullPointerException
              at org.forgerock.openam.core.rest.sms.SmsResourceProvider.checkedInstanceSubConfig(SmsResourceProvider.java:352)
              at org.forgerock.openam.core.rest.sms.SmsCollectionProvider.readInstance(SmsCollectionProvider.java:353)
              ... 154 more
      Expected behaviour
      SmsResourceProvider shouldn't fail with 500 response code
      Current behaviour
      request to get authentication module config throws 500 Internal Error

      Work around

      OPTIONAL - If you have a workaround, please put the details here (remove this text)

      Code analysis

      It seems like this error occur when realm was removed and auth module was requested for non-existent realm. As a result of fixing OPENAM-17317, loading/unloading AMAuthenticationManager related data was improved. This lead to SmsResourceProvider being able to slip in between RealmRoutingFactory returning "Realm not found" and SmsResourceProvider trying to get ServiceConfig. The solution would be to add null check

          protected ServiceConfig checkedInstanceSubConfig(Context context, ServiceConfigManager scm, String resourceId)
                  throws SSOException, SMSException, NotFoundException {
              ServiceConfig config = parentSubConfigFor(context, scm);
              if (config != null && CollectionUtils.isNotEmpty(config.getSubConfigNames()) && config.getSubConfigNames().contains(resourceId)) {  <--- HERE
                  ServiceConfig subConfig = config.getSubConfig(resourceId);
                  if (subConfig == null || !subConfig.getSchemaID().equals(lastSchemaNodeName()) || !subConfig.exists()) {
                      throw new NotFoundException();




            Unassigned Unassigned
            sachiko Sachiko Wallace
            0 Vote for this issue
            4 Start watching this issue