Uploaded image for project: 'Syncope'
  1. Syncope
  2. SYNCOPE-1430

ItemTransformer for Date schemas throws NPE

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.12, 2.1.3
    • 2.0.13, 2.1.4, 3.0.0-M0
    • core
    • None

    Description

      1. Login as admin to console
      2. Define a connector and a resource (say resource-ldap on embedded mode). 
      3. Create a USER mapping and map, for example, a Date attribute (say loginDate) with a string value on the resource (say street on ldap, does not matter the meaning)
      4. Define a JEXL transformer for that mapping row like this 
        value.toString().contains("T") ? value.toString().split("T")[0].replaceAll("-", "") : value  

        Or a Java/Groovy transformer with this beforePropagation:

            public List<PlainAttrValue> beforePropagation(
                    final Item item, 
                    final Entity entity, 
                    final List<PlainAttrValue> values) {
                
                if (values != null && !values.isEmpty()) {
                    values.forEach(value -> {
                        Date originalValue = value.getDateValue();
                        if (originalValue != null) {
                            value.setBinaryValue(null);
                            value.setBooleanValue(null);
                            value.setDateValue(null);
                            value.setDoubleValue(null);
                            value.setLongValue(null);
                            value.setStringValue(makeSomeChanges(values.get(0).getDateValue()));
                        }
                    });
                }
                return values;
            }
        

      You will notice that the value propagated is not the one changed by the transformer, sometimes (like this case) you'll get an NPE:

      14:40:47.203 ERROR org.apache.syncope.core.provisioning.api.MappingManager - Expression 'loginDate' processing failed
      java.lang.NullPointerException: null
              at java.util.Calendar.setTime(Calendar.java:1770) ~[?:1.8.0_191]
              at java.text.SimpleDateFormat.format(SimpleDateFormat.java:943) ~[?:1.8.0_191]
              at java.text.SimpleDateFormat.format(SimpleDateFormat.java:936) ~[?:1.8.0_191]
              at java.text.DateFormat.format(DateFormat.java:345) ~[?:1.8.0_191]
              at org.apache.syncope.core.provisioning.api.utils.FormatUtils.format(FormatUtils.java:72) ~[syncope-core-provisioning-api-2.1.3.jar:2.1.3]
              at org.apache.syncope.core.provisioning.api.utils.FormatUtils.format(FormatUtils.java:58) ~[syncope-core-provisioning-api-2.1.3.jar:2.1.3]
              at org.apache.syncope.core.provisioning.api.utils.FormatUtils.format(FormatUtils.java:54) ~[syncope-core-provisioning-api-2.1.3.jar:2.1.3]
              at org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue.getValueAsString(AbstractPlainAttrValue.java:233) ~[syncope-core-persistence-jpa-2.1.3.jar:2.1.3]
              at org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue.getValueAsString(AbstractPlainAttrValue.java:273) ~[syncope-core-persistence-jpa-2.1.3.jar:2.1.3]
              at org.apache.syncope.core.provisioning.java.MappingManagerImpl.prepareAttr(MappingManagerImpl.java:365) ~[syncope-core-provisioning-java-2.1.3.jar:2.1.3]
              at org.apache.syncope.core.provisioning.java.MappingManagerImpl.prepareAttrs(MappingManagerImpl.java:178) ~[syncope-core-provisioning-java-2.1.3.jar:2.1.3]
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_191]
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_191]
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]
              at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]
              at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) ~[spring-aop-5.1.4.RELEASE.jar:5.1.4.RELEASE]
              at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) ~[spring-aop-5.1.4.RELEASE.jar:5.1.4.RELEASE]
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.1.4.RELEASE.jar:5.1.4.RELEASE]
              at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294) ~[spring-tx-5.1.4.RELEASE.jar:5.1.4.RELEASE]
              at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98) ~[spring-tx-5.1.4.RELEASE.jar:5.1.4.RELEASE]
              at org.apache.syncope.core.persistence.jpa.spring.DomainTransactionInterceptor.invoke(DomainTransactionInterceptor.java:60) ~[syncope-core-persistence-jpa-2.1.3.jar:2.1.3]
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.4.RELEASE.jar:5.1.4.RELEASE]
              at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.1.4.RELEASE.jar:5.1.4.RELEASE]
              at com.sun.proxy.$Proxy632.prepareAttrs(Unknown Source) ~[?:?]
              at org.apache.syncope.core.provisioning.java.propagation.PropagationManagerImpl.lambda$createTasks$4(PropagationManagerImpl.java:396) ~[syncope-core-provisioning-java-2.1.3.jar:2.1.3]
              at java.util.HashMap.forEach(HashMap.java:1289) ~[?:1.8.0_191]
              at org.apache.syncope.core.provisioning.java.propagation.PropagationManagerImpl.createTasks(PropagationManagerImpl.java:368) ~[syncope-core-provisioning-java-2.1.3.jar:2.1.3]
              at org.apache.syncope.core.provisioning.java.propagation.PropagationManagerImpl.getUpdateTasks(PropagationManagerImpl.java:265) ~[syncope-core-provisioning-java-2.1.3.jar:2.1.3]
              at org.apache.syncope.core.provisioning.java.propagation.PropagationManagerImpl.getUserUpdateTasks(PropagationManagerImpl.java:197) ~[syncope-core-provisioning-java-2.1.3.jar:2.1.3]
              at org.apache.syncope.core.provisioning.java.propagation.PropagationManagerImpl.getUserUpdateTasks(PropagationManagerImpl.java:217) ~[syncope-core-provisioning-java-2.1.3.jar:2.1.3]
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_191]
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_191]
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]
              at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]
              at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) ~[spring-aop-5.1.4.RELEASE.jar:5.1.4.RELEASE]
              at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) ~[spring-aop-5.1.4.RELEASE.jar:5.1.4.RELEASE]
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.1.4.RELEASE.jar:5.1.4.RELEASE]
              at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294) ~[spring-tx-5.1.4.RELEASE.jar:5.1.4.RELEASE]
              at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98) ~[spring-tx-5.1.4.RELEASE.jar:5.1.4.RELEASE]
              at org.apache.syncope.core.persistence.jpa.spring.DomainTransactionInterceptor.invoke(DomainTransactionInterceptor.java:60) ~[syncope-core-persistence-jpa-2.1.3.jar:2.1.3]
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.4.RELEASE.jar:5.1.4.RELEASE]
              at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.1.4.RELEASE.jar:5.1.4.RELEASE]
              at com.sun.proxy.$Proxy697.getUserUpdateTasks(Unknown Source) ~[?:?]
              at org.apache.syncope.core.provisioning.java.DefaultUserProvisioningManager.update(DefaultUserProvisioningManager.java:118) ~[syncope-core-provisioning-java-2.1.3.jar:2.1.3]
              at org.apache.syncope.core.provisioning.java.DefaultUserProvisioningManager.update(DefaultUserProvisioningManager.java:58) ~[syncope-core-provisioning-java-2.1.3.jar:2.1.3]
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_191]
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_191]
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_191]
              at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_191]
              at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) ~[spring-aop-5.1.4.RELEASE.jar:5.1.4.RELEASE]
              at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:206) ~[spring-aop-5.1.4.RELEASE.jar:5.1.4.RELEASE]
      

      Attachments

        Activity

          People

            ilgrosso Francesco Chicchiriccò
            andrea.patricelli Andrea Patricelli
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: