mirror of https://github.com/apache/nifi.git
NIFI-5045: Fixed error code handling in PutHiveQL. This closes #2608
This commit is contained in:
parent
c119547222
commit
7ff38f690d
|
@ -146,7 +146,21 @@ public class PutHiveQL extends AbstractHiveQLProcessor {
|
|||
if (e instanceof SQLNonTransientException) {
|
||||
return ErrorTypes.InvalidInput;
|
||||
} else if (e instanceof SQLException) {
|
||||
return ErrorTypes.TemporalFailure;
|
||||
// Use the SQLException's vendor code for guidance -- see Hive's ErrorMsg class for details on error codes
|
||||
int errorCode = ((SQLException) e).getErrorCode();
|
||||
if (errorCode >= 10000 && errorCode < 20000) {
|
||||
return ErrorTypes.InvalidInput;
|
||||
} else if (errorCode >= 20000 && errorCode < 30000) {
|
||||
return ErrorTypes.TemporalFailure;
|
||||
} else if (errorCode >= 30000 && errorCode < 40000) {
|
||||
return ErrorTypes.TemporalInputFailure;
|
||||
} else if (errorCode >= 40000 && errorCode < 50000) {
|
||||
// These are unknown errors (to include some parse errors), but rather than generating an UnknownFailure which causes
|
||||
// a ProcessException, we'll route to failure via an InvalidInput error type.
|
||||
return ErrorTypes.InvalidInput;
|
||||
} else {
|
||||
return ErrorTypes.UnknownFailure;
|
||||
}
|
||||
} else {
|
||||
return ErrorTypes.UnknownFailure;
|
||||
}
|
||||
|
|
|
@ -773,7 +773,8 @@ public class TestPutHiveQL {
|
|||
try {
|
||||
if (++successful > allowedBeforeFailure) {
|
||||
final Connection conn = Mockito.mock(Connection.class);
|
||||
Mockito.when(conn.prepareStatement(Mockito.any(String.class))).thenThrow(new SQLException("Unit Test Generated SQLException"));
|
||||
// Throw a retryable error
|
||||
Mockito.when(conn.prepareStatement(Mockito.any(String.class))).thenThrow(new SQLException("Unit Test Generated SQLException", "42000", 20000));
|
||||
return conn;
|
||||
} else {
|
||||
return service.getConnection();
|
||||
|
|
Loading…
Reference in New Issue