Uploaded image for project: 'Talend Component Kit'
  1. Talend Component Kit
  2. TCOMP-2626

Handle the "null" string value in MappingUtils

Apply templateInsert Lucidchart Diagram
    XMLWordPrintable

Details

    • All
    • Small

    Description

      During record type/value conversions when we have a String and the expected mapping type is another type, we use the mapString method:
      https://github.com/Talend/component-runtime/blob/63868c4fc65c9e03b8bc5c482bd6b48d35dae524/component-runtime-impl/src/main/java/org/talend/sdk/component/runtime/record/MappingUtils.java#L180

      This method use mainly Type.valueOf(final String v) for coercision.
      The issue happens when the value to coerce is the String literal "null" which leads to a type conversion exception.

      Caused by: java.lang.NumberFormatException: For input string: "null"
              at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[?:?]
              at java.lang.Integer.parseInt(Integer.java:652) ~[?:?]
              at java.lang.Integer.valueOf(Integer.java:983) ~[?:?]
              at org.talend.sdk.component.runtime.record.MappingUtils.mapString(MappingUtils.java:219) ~[component-runtime-impl-1.64.0.jar!/:?]
              at org.talend.sdk.component.runtime.record.MappingUtils.coerce(MappingUtils.java:114) ~[component-runtime-impl-1.64.0.jar!/:?]
              at org.talend.sdk.component.runtime.di.record.DiRecordVisitor.setField(DiRecordVisitor.java:333) ~[component-runtime-di-1.64.0.jar!/:?]
              at org.talend.sdk.component.runtime.di.record.DiRecordVisitor.lambda$onString$31(DiRecordVisitor.java:372) ~[component-runtime-di-1.64.0.jar!/:?]
              at java.util.Optional.ifPresent(Optional.java:183) ~[?:?]
              at org.talend.sdk.component.runtime.di.record.DiRecordVisitor.onString(DiRecordVisitor.java:372) ~[component-runtime-di-1.64.0.jar!/:?]
              at org.talend.sdk.component.runtime.manager.service.RecordServiceImpl.lambda$visit$7(RecordServiceImpl.java:119) ~[component-runtime-manager-1.64.0.jar!/:?]
              at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655) ~[?:?]
              at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735) ~[?:?]
              at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658) ~[?:?]
              at org.talend.sdk.component.runtime.manager.service.RecordServiceImpl.visit(RecordServiceImpl.java:97) ~[component-runtime-manager-1.64.0.jar!/:?]
              at org.talend.sdk.component.runtime.di.record.DiRecordVisitor.visit(DiRecordVisitor.java:200) ~[component-runtime-di-1.64.0.jar!/:?]
              at jdk.internal.reflect.GeneratedMethodAccessor32.invoke(Unknown Source) ~[?:?]
              at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
              at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
              at org.talend.sdk.component.runtime.record.RecordConverters$MappingMeta.newInstance(RecordConverters.java:502) ~[component-runtime-impl-1.64.0.jar!/:?]
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            emmanuel_g emmanuel gallois
            emmanuel gallois, Fabien Desiles
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: