Daniel Stieglitz created NIFI-16049:
---------------------------------------

             Summary: Correct if else logic in FlowFileUnpackagerV1 when 
checking key and value of attributes should both be strings
                 Key: NIFI-16049
                 URL: https://issues.apache.org/jira/browse/NIFI-16049
             Project: Apache NiFi
          Issue Type: Bug
            Reporter: Daniel Stieglitz
            Assignee: Daniel Stieglitz


On lines 78-94 in FlowFileUnpackagerV1, the current logic below checks 
keyObject in both the if and else if branches to check if its not a String. 
Based on the message in the else if it would appear it should be checking the 
valueObject. Also this should not be an else if but rather two separate if 
statements each checking the keyObject and valueObject respectively.

 
{code:java}
for (final Entry<Object, Object> entry : props.entrySet()) {
            final Object keyObject = entry.getKey();
            final Object valueObject = entry.getValue();
            if (!(keyObject instanceof String)) {
                throw new IOException("Flow file attributes object contains key 
of type "
                        + keyObject.getClass().getCanonicalName()
                        + " but expected java.lang.String");
            } else if (!(keyObject instanceof String)) {
                throw new IOException("Flow file attributes object contains 
value of type "
                        + keyObject.getClass().getCanonicalName()
                        + " but expected java.lang.String");
            }
            final String key = (String) keyObject;
            final String value = (String) valueObject;
            result.put(key, value);
        }
{code}
 

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to