-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JDBC Sources: Wrap SQLTransientException with ConfigErrorException #19711
Changes from 6 commits
f4df336
e452097
437d013
b24ab14
7bdcbeb
2266169
99cd2d8
b4c8056
d520524
9918bfc
7161efd
f88f7b4
8f402b7
5a56eaa
acbded7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
package io.airbyte.db.jdbc; | ||
|
||
import com.google.errorprone.annotations.MustBeClosed; | ||
import io.airbyte.commons.exceptions.ConfigErrorException; | ||
import io.airbyte.commons.exceptions.ConnectionErrorException; | ||
import io.airbyte.commons.functional.CheckedConsumer; | ||
import io.airbyte.commons.functional.CheckedFunction; | ||
|
@@ -14,6 +15,7 @@ | |
import java.sql.PreparedStatement; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.sql.SQLTransientException; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.stream.Collectors; | ||
|
@@ -79,6 +81,12 @@ public DatabaseMetaData getMetaData() throws SQLException { | |
final DatabaseMetaData metaData = connection.getMetaData(); | ||
return metaData; | ||
} catch (final SQLException e) { | ||
if (e instanceof SQLTransientException) { | ||
final String message = e.getMessage(); | ||
if (message.contains("request timed out")) { | ||
throw new ConfigErrorException("Connection timed out. Unable to contact server."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because it's a transient error, I wonder if adding something like "Please try again later" is appropriate, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@rodireich the connection timeout can be not only because there is some problem with the existing server, but also because if the user pushed the wrong host / port on UI which will also lead to a timeout, so just adding "Please try again later" will be not entirely correct. Might be better to use - "Please check your server settings or try again later". What do you think about it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. thank you for explaining! |
||
} | ||
} | ||
// Some databases like Redshift will have null cause | ||
if (Objects.isNull(e.getCause()) || !(e.getCause() instanceof SQLException)) { | ||
throw new ConnectionErrorException(e.getSQLState(), e.getErrorCode(), e.getMessage(), e); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build error is linting. Make a separate catch statement