mirror of https://github.com/apache/nifi.git
NIFI-9800: Unwrap SQLException in PutDatabaseRecord when table does not exist
Signed-off-by: Matthew Burgess <mattyb149@apache.org> This closes #5871
This commit is contained in:
parent
2dc23e7309
commit
c84f438782
|
@ -604,17 +604,28 @@ public class PutDatabaseRecord extends AbstractProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
final SchemaKey schemaKey = new PutDatabaseRecord.SchemaKey(catalog, schemaName, tableName);
|
final SchemaKey schemaKey = new PutDatabaseRecord.SchemaKey(catalog, schemaName, tableName);
|
||||||
final TableSchema tableSchema = schemaCache.get(schemaKey, key -> {
|
final TableSchema tableSchema;
|
||||||
try {
|
try {
|
||||||
final TableSchema schema = TableSchema.from(con, catalog, schemaName, tableName, settings.translateFieldNames, updateKeys, log);
|
tableSchema = schemaCache.get(schemaKey, key -> {
|
||||||
getLogger().debug("Fetched Table Schema {} for table name {}", schema, tableName);
|
try {
|
||||||
return schema;
|
final TableSchema schema = TableSchema.from(con, catalog, schemaName, tableName, settings.translateFieldNames, updateKeys, log);
|
||||||
} catch (SQLException e) {
|
getLogger().debug("Fetched Table Schema {} for table name {}", schema, tableName);
|
||||||
throw new ProcessException(e);
|
return schema;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
// Wrap this in a runtime exception, it is unwrapped in the outer try
|
||||||
|
throw new ProcessException(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (tableSchema == null) {
|
||||||
|
throw new IllegalArgumentException("No table schema specified!");
|
||||||
|
}
|
||||||
|
} catch (ProcessException pe) {
|
||||||
|
// Unwrap the SQLException if one occurred
|
||||||
|
if (pe.getCause() instanceof SQLException) {
|
||||||
|
throw (SQLException) pe.getCause();
|
||||||
|
} else {
|
||||||
|
throw pe;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
if (tableSchema == null) {
|
|
||||||
throw new IllegalArgumentException("No table schema specified!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// build the fully qualified table name
|
// build the fully qualified table name
|
||||||
|
|
Loading…
Reference in New Issue