exceptionfactory commented on code in PR #11850:
URL: https://github.com/apache/nifi/pull/11850#discussion_r4381644205
##########
nifi-extension-bundles/nifi-jslt-bundle/nifi-jslt-processors/src/main/java/org/apache/nifi/processors/jslt/JSLTTransformJSON.java:
##########
@@ -476,14 +476,26 @@ private FlowFile transformJsonLines(final Expression
jsltExpression, final FlowF
try (final BufferedReader reader = new BufferedReader(new
InputStreamReader(inputStream, StandardCharsets.UTF_8));
final JsonGenerator jsonGenerator =
writer.createGenerator(outputStream)) {
String line;
+ int lines = 0;
+ int matches = 0;
while ((line = reader.readLine()) != null) {
if (line.isBlank()) {
continue;
}
+ lines++;
final JsonNode jsonNode =
JSON_OBJECT_MAPPER.readTree(line);
final JsonNode transformedJson =
jsltExpression.apply(jsonNode);
- jsonGenerator.writeObject(transformedJson);
+ if (transformedJson == null || transformedJson.isNull()) {
+ getLogger().debug("JSLT Transform resulted in no data
{}", line);
Review Comment:
It would be better to log the line number:
```suggestion
getLogger().debug("JSLT Transform resulted in no
data on line {}", lines);
```
##########
nifi-extension-bundles/nifi-jslt-bundle/nifi-jslt-processors/src/main/java/org/apache/nifi/processors/jslt/JSLTTransformJSON.java:
##########
@@ -476,14 +476,26 @@ private FlowFile transformJsonLines(final Expression
jsltExpression, final FlowF
try (final BufferedReader reader = new BufferedReader(new
InputStreamReader(inputStream, StandardCharsets.UTF_8));
final JsonGenerator jsonGenerator =
writer.createGenerator(outputStream)) {
String line;
+ int lines = 0;
+ int matches = 0;
while ((line = reader.readLine()) != null) {
if (line.isBlank()) {
continue;
}
+ lines++;
final JsonNode jsonNode =
JSON_OBJECT_MAPPER.readTree(line);
final JsonNode transformedJson =
jsltExpression.apply(jsonNode);
- jsonGenerator.writeObject(transformedJson);
+ if (transformedJson == null || transformedJson.isNull()) {
+ getLogger().debug("JSLT Transform resulted in no data
{}", line);
+ } else {
+ jsonGenerator.writeObject(transformedJson);
+ matches++;
+ }
+ }
+
+ if (lines > 0 && lines != matches) {
+ getLogger().warn("JSLT Transform resulted in data for {}
out of {} lines", matches, lines);
Review Comment:
I'm not sure this should be a warning, `info` seems like the better level
given that it could be expected.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]