NIFI-11666 Added Exception to Error Log for ModifyCompression

Signed-off-by: Matt Burgess <mattyb149@apache.org>

This closes #7360
This commit is contained in:
exceptionfactory 2023-06-08 08:49:02 -05:00 committed by Matt Burgess
parent f3e8651522
commit 4509f5de80
2 changed files with 11 additions and 1 deletions

View File

@ -277,7 +277,7 @@ public class ModifyCompression extends AbstractProcessor {
session.transfer(flowFile, REL_SUCCESS);
} catch (final RuntimeException e) {
getLogger().error("Input Compression [{}] Size [{}] Output Compression [{}] Failed {}",
inputCompressionStrategy, inputFileSize, outputCompressionStrategy, flowFile);
inputCompressionStrategy, inputFileSize, outputCompressionStrategy, flowFile, e);
session.transfer(flowFile, REL_FAILURE);
}
}

View File

@ -19,6 +19,7 @@ package org.apache.nifi.processors.compress;
import org.apache.nifi.flowfile.attributes.CoreAttributes;
import org.apache.nifi.processors.compress.property.CompressionStrategy;
import org.apache.nifi.processors.compress.property.FilenameStrategy;
import org.apache.nifi.util.LogMessage;
import org.apache.nifi.util.MockFlowFile;
import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners;
@ -28,9 +29,12 @@ import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
class TestModifyCompression {
@ -292,6 +296,12 @@ class TestModifyCompression {
runner.assertAllFlowFilesTransferred(ModifyCompression.REL_FAILURE, 1);
runner.getFlowFilesForRelationship(ModifyCompression.REL_FAILURE).get(0).assertContentEquals(data);
final LogMessage errorMessage = runner.getLogger().getErrorMessages().iterator().next();
assertNotNull(errorMessage);
final Optional<Object> exceptionFound = Arrays.stream(errorMessage.getArgs()).filter(Exception.class::isInstance).findFirst();
assertTrue(exceptionFound.isPresent());
}
@Test