[
https://issues.apache.org/jira/browse/NIFI-4802?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16555062#comment-16555062
]
ASF GitHub Bot commented on NIFI-4802:
--------------------------------------
Github user jvwing commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2859#discussion_r204968906
--- Diff:
nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/sqs/PutSQS.java
---
@@ -115,7 +125,19 @@ public void onTrigger(final ProcessContext context,
final ProcessSession session
entry.setId(flowFile.getAttribute("uuid"));
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
session.exportTo(flowFile, baos);
- final String flowFileContent = baos.toString();
+
+ final Charset charset =
Charset.forName(context.getProperty(CHARSET).getValue());
+
+ String flowFileContent;
+
+ // Get the content of the FlowFile with the given Charset. Fall
back to the default charset
+ // if the given charset is not supported.
+ try {
+ flowFileContent = baos.toString(charset.name());
+ } catch (UnsupportedEncodingException e) {
--- End diff --
`customValidate` is defined in `AbstractConfigurableComponent`, but can be
overridden in processors to validate properties as the processor is started,
before `onTrigger` is ever called. Take a look at
[PutCloudWatchMetric.customValidate](https://github.com/apache/nifi/blob/2834fa4ce477014dfad8c96b6d326d0f1f06a23e/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/cloudwatch/PutCloudWatchMetric.java#L216)
for a good example.
* It's important to call `super.customValidate()` to get validation for
inherited property descriptors.
* I also recommend TestPutCloudWatchMetric for several examples on how to
unit test the validation cases.
> PutSQS not UTF-8 encoding output
> --------------------------------
>
> Key: NIFI-4802
> URL: https://issues.apache.org/jira/browse/NIFI-4802
> Project: Apache NiFi
> Issue Type: Bug
> Components: Extensions
> Affects Versions: 1.4.0
> Environment: OSX, Linux
> Reporter: Richard St. John
> Priority: Major
>
> PutSQS processor does not properly encode content. Line 117 reads,
> {code:java}
> final string flowFileContent = baos.toString();
> {code}
> Instead, the output stream should default to UTF-8, or have a configuration
> similar to GetSQS.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)