exceptionfactory commented on code in PR #6853:
URL: https://github.com/apache/nifi/pull/6853#discussion_r1095101696
##########
nifi-nar-bundles/nifi-extension-utils/nifi-database-utils/src/main/java/org/apache/nifi/util/db/JdbcCommon.java:
##########
@@ -711,18 +711,59 @@ public static void setParameters(final PreparedStatement
stmt, final Map<String,
}
}
+ /**
+ * Sets all of the appropriate parameters on the given PreparedStatement,
based on the given FlowFile attributes.
+ *
+ * @param stmt the statement to set the parameters on
+ * @param attributes the attributes from which to derive parameter
indices, values, and types
+ * @throws SQLException if the PreparedStatement throws a SQLException
when the appropriate setter is called
+ */
+ public static void setSensitiveParameters(final PreparedStatement stmt,
final Map<String, SensitiveValueWrapper> attributes) throws SQLException {
+ for (final Map.Entry<String, SensitiveValueWrapper> entry :
attributes.entrySet()) {
+ final String key = entry.getKey();
+ final boolean isSensitive = entry.getValue().isSensitive();
+ final String value = entry.getValue().getValue();
+ final String logValue = isSensitive ? "???" : value;
+ final Matcher matcher = SQL_TYPE_ATTRIBUTE_PATTERN.matcher(key);
+ if (matcher.matches()) {
+ final int parameterIndex = Integer.parseInt(matcher.group(1));
+
+ final boolean isNumeric =
NUMBER_PATTERN.matcher(value).matches();
+ if (!isNumeric) {
+ throw new SQLDataException("Value of the " + key + "
attribute is '" + logValue + "', which is not a valid JDBC numeral type");
Review Comment:
In this case, including `logValue` in the error does not seem helpful,
because it does not help to troubleshoot a non-numeric type. Including the
`key` and expected type should be sufficient.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]