[
https://issues.apache.org/jira/browse/NIFI-5744?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16690532#comment-16690532
]
ASF GitHub Bot commented on NIFI-5744:
--------------------------------------
Github user yjhyjhyjh0 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/3107#discussion_r234407245
--- Diff:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteSQLRecord.java
---
@@ -350,6 +357,37 @@ public void invokeOnTriggerRecords(final Integer
queryTimeout, final String quer
assertEquals(durationTime, fetchTime + executionTime);
}
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testWithSqlExceptionErrorProcessingResultSet() throws
Exception {
+ DBCPService dbcp = mock(DBCPService.class);
+ Connection conn = mock(Connection.class);
+ when(dbcp.getConnection(any(Map.class))).thenReturn(conn);
+ when(dbcp.getIdentifier()).thenReturn("mockdbcp");
+ PreparedStatement statement = mock(PreparedStatement.class);
+ when(conn.prepareStatement(anyString())).thenReturn(statement);
+ when(statement.execute()).thenReturn(true);
+ ResultSet rs = mock(ResultSet.class);
+ when(statement.getResultSet()).thenReturn(rs);
+ // Throw an exception the first time you access the ResultSet,
this is after the flow file to hold the results has been created.
+ when(rs.getMetaData()).thenThrow(new SQLException("test execute
statement failed"));
+
--- End diff --
You're right, thanks for point out and suggestion.
I should be more cautious while resolving commit.
I've add lines of mock record writer back and test successfully.
Squashed and pushed.
> Put exception message to attribute while ExecuteSQL fail
> --------------------------------------------------------
>
> Key: NIFI-5744
> URL: https://issues.apache.org/jira/browse/NIFI-5744
> Project: Apache NiFi
> Issue Type: Improvement
> Affects Versions: 1.7.1
> Reporter: Deon Huang
> Assignee: Deon Huang
> Priority: Minor
>
> In some scenario, it would be great if we could have different behavior based
> on exception.
> Better error tracking afterwards in attribute format instead of tracking in
> log.
> For example, if it’s connection refused exception due to wrong url.
> We won’t want to retry and error message attribute would be helpful to keep
> track of.
> While it’s other scenario that database temporary unavailable, we should
> retry it based on should retry exception.
> Should be a quick fix at AbstractExecuteSQL before transfer flowfile to
> failure relationship
> {code:java}
> session.transfer(fileToProcess, REL_FAILURE);
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)