kevdoran commented on a change in pull request #5458: URL: https://github.com/apache/nifi/pull/5458#discussion_r738512134
########## File path: nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/StringUtils.java ########## @@ -510,4 +514,27 @@ public static String toTitleCase(String input) { .map(word -> Character.toTitleCase(word.charAt(0)) + word.substring(1)) .collect(Collectors.joining(" ")); } + + /** + * Escape {@code str} by replacing occurrences of {@code charToEscape} with {@code escapeChar+charToEscape} + * @param str the input string + * @param escapeChar the character used for escaping + * @param charToEscape the character that needs to be escaped + * @return the escaped string + */ + public static String escapeString(String str, char escapeChar, char charToEscape) { + if (str == null || str.isEmpty()) { + return null; + } + StringBuilder result = new StringBuilder(); + for (int i=0; i<str.length(); i++) { + char curChar = str.charAt(i); + if (curChar == escapeChar || curChar == charToEscape) { + // special char + result.append(escapeChar); + } + result.append(curChar); Review comment: I see. It seems that semantics of this method are important to ConsumeAMQP and PublishAMQP. It might be better to put this is a package-private class in `org.apache.nifi.amqp.processors` and only use it there. Then the logic would not have to be generalized, so it could be made potentially more robust for this use case, and for maintainability it protect developers from unintentionally modifying this logic in the future in a way that breaks the expectation of PublishAMQP ########## File path: nifi-nar-bundles/nifi-amqp-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java ########## @@ -99,6 +101,16 @@ .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .build(); + static final PropertyDescriptor UNESCAPE_COMMA = new PropertyDescriptor.Builder() + .name("unescape.comma") Review comment: The property naming convention here should be consistent with other properties in this processor. So with existing properties named `Exchange Name` and `Routing Key`, I would expect this to be `Unescape Comma`. -- 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: issues-unsubscr...@nifi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org