[ https://issues.apache.org/jira/browse/NIFI-12554?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17804436#comment-17804436 ]
Daniel Stieglitz commented on NIFI-12554: ----------------------------------------- [~exceptionfactory] I am in the midst of trying to pull up the common pieces of code found in JolTransformJSON and JoltTransformRecord. In particular I am focusing right now on the customValidate method found in both processors. It is more or less the same except for some key differences I would like to highlight and get some guidance on how to move forward with. # JoltTransformRecord does not duplicate two variables like JoltTransformJSON does with joltSpecBody and specValue rather it just has joltSpecValue. I am inclined to adapt the way JoltTransformRecord does this. # For the first if statement in the try catch block {code:java} if (modulePath != null && !validationContext.isExpressionLanguagePresent(modulePath)) {code} JoltTransformJSON has the && clause while JoltTransformRecord left it out. I am not sure why and hence I am not sure how to handle this scenario. To me it seems the JoltTransformJSON is correct. # As part of the if(elPresent) line in the try catch block, JoltTransformJson has an else if statement while JoltTransformRecord does not. I am inclined to believe JolTransformJson has the correct code for this. {code:java} else if (validationContext.isExpressionLanguagePresent(customTransform)) { final String invalidExpressionMsg = validationContext.newExpressionLanguageCompiler().validateExpression(customTransform, true); if (!StringUtils.isEmpty(invalidExpressionMsg)) { results.add(new ValidationResult.Builder().valid(false) .subject(CUSTOM_CLASS.getDisplayName()) .explanation("Invalid Expression Language: " + invalidExpressionMsg) .build()); } {code} # In the catch block JolTransformJSON includes the stacktrace of the exception caught as part of the message while JoltTransformRecord does not but rather logs the exception. I would like to include as part of the validation the exception message and perhaps log the whole stacktrace as JoltTransformRecord does. > Refactor JoltTransformJSON and JoltTransformRecord processors in order to > reduce duplicate code > ----------------------------------------------------------------------------------------------- > > Key: NIFI-12554 > URL: https://issues.apache.org/jira/browse/NIFI-12554 > Project: Apache NiFi > Issue Type: Sub-task > Reporter: Daniel Stieglitz > Assignee: Daniel Stieglitz > Priority: Major > > There is a lot of duplicate code between the JoltTransformJSON and > JoltTransformRecord processors. As a result each time there is a bug > discovered in the duplicate code there has to be a fix applied in both places > (e.g. NIFI-11959 and NIFI-12165). This ticket aims to pull up the common > code between JoltTransformJSON and JoltTransformRecord similar to what has > been done for PutElastisearchJSON and PutElastisearchRecord processors with > the creation of AbstractPutElasticsearch. -- This message was sent by Atlassian Jira (v8.20.10#820010)