[
https://issues.apache.org/jira/browse/NIFI-3142?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15722712#comment-15722712
]
ASF GitHub Bot commented on NIFI-3142:
--------------------------------------
Github user klinvill commented on a diff in the pull request:
https://github.com/apache/nifi/pull/1290#discussion_r90904513
--- Diff:
nifi-nar-bundles/nifi-hl7-bundle/nifi-hl7-processors/src/main/java/org/apache/nifi/processors/hl7/ExtractHL7Attributes.java
---
@@ -196,8 +196,8 @@ public void process(final InputStream in) throws
IOException {
final Map<String, String> attributes = getAttributes(message,
useSegmentNames, parseSegmentFields);
flowFile = session.putAllAttributes(flowFile, attributes);
getLogger().debug("Added the following attributes for {}: {}",
new Object[]{flowFile, attributes});
- } catch (final HL7Exception e) {
- getLogger().error("Failed to extract attributes from {} due to
{}", new Object[]{flowFile, e});
+ } catch (final Throwable t) {
--- End diff --
Thanks for taking a look Matt. The two exceptions I was seeing were a
java.lang.NullPointerException (when using a non-recognized segment name) and a
java.lang.NumberFormatException (when the first field after the segment name
had a code such as RE instead of a sequence number). Both of these exceptions
were due to how the processor tries to process the HL7 segments and both were
causing the processor to backup after enough messages failed to process and
were not routed to failure (or anywhere for that matter). I could catch these
two exceptions explicitly but I'd prefer that any error (even an error coming
from nifi) cause the flowfile to be routed to failure so that it doesn't backup
any of the flowfiles that could be processed successfully. I thought catching
at the throwable level would work out well since it looks like that's how the
PutHDFS processor checks for failure. Do you disagree?
> ExtractHL7Attributes processor does not route to REL_FAILURE for an exception
> other than an HL7Exception
> --------------------------------------------------------------------------------------------------------
>
> Key: NIFI-3142
> URL: https://issues.apache.org/jira/browse/NIFI-3142
> Project: Apache NiFi
> Issue Type: Bug
> Components: Extensions
> Affects Versions: 1.0.0
> Reporter: Kirby Linvill
> Priority: Minor
> Labels: easyfix
>
> The ExtractHL7Attribute processor will not route a flowfile to REL_FAILURE if
> processing the flow file throws an exception that is not an HL7Exception.
> This bug is a result of the try catch block in the onTrigger method. It is
> easily fixed by changing the catch block to catch a throwable object. Change
> {noformat}
> try {
> ...
> } catch (final HL7Exception e) {
> getLogger().error("Failed to extract attributes from {} due to {}", new
> Object[]{flowFile, e}, e);
> session.transfer(flowFile, REL_FAILURE);
> return;
> }
> {noformat}
> to
> {noformat}
> try {
> ...
> } catch (final Throwable t) {
> getLogger().error("Failed to extract attributes from {} due to {}", new
> Object[]{flowFile, t}, t);
> session.transfer(flowFile, REL_FAILURE);
> return;
> }
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)