Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,36 @@ public final int getBaseType() {

@Override
public final Object getArray(Map<String, Class<?>> map) throws SQLException {
LOG.severe(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
throw new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
BigQueryJdbcSqlFeatureNotSupportedException ex =
new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
LOG.severe(ex, CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
throw ex;
}

@Override
public final Object getArray(long index, int count, Map<String, Class<?>> map)
throws SQLException {
LOG.severe(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
throw new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
BigQueryJdbcSqlFeatureNotSupportedException ex =
new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
LOG.severe(ex, CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
throw ex;
}

@Override
public final ResultSet getResultSet(Map<String, Class<?>> map) throws SQLException {
LOG.severe(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
throw new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
BigQueryJdbcSqlFeatureNotSupportedException ex =
new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
LOG.severe(ex, CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
throw ex;
}

@Override
public final ResultSet getResultSet(long index, int count, Map<String, Class<?>> map)
throws SQLException {
LOG.severe(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
throw new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
BigQueryJdbcSqlFeatureNotSupportedException ex =
new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
LOG.severe(ex, CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
throw ex;
}

protected Object getArrayInternal(int fromIndex, int toIndexExclusive) {
Expand All @@ -110,8 +118,9 @@ protected Object getArrayInternal(int fromIndex, int toIndexExclusive) {
protected void ensureValid() throws IllegalStateException {
LOG.finest("++enter++");
if (!this.valid) {
LOG.severe(INVALID_ARRAY);
throw new IllegalStateException(INVALID_ARRAY);
IllegalStateException ex = new IllegalStateException(INVALID_ARRAY);
LOG.severe(ex, INVALID_ARRAY);
throw ex;
}
}

Expand All @@ -132,11 +141,13 @@ protected Tuple<Integer, Integer> createRange(long index, int count, int size)
// jdbc array follows 1 based array indexing
long normalisedFromIndex = index - 1;
if (normalisedFromIndex + count > size) {
LOG.severe(
"The array index is out of range: %d, number of elements: %d.", index + count, size);
throw new IllegalArgumentException(
String.format(
"The array index is out of range: %d, number of elements: %d.", index + count, size));
IllegalArgumentException ex =
new IllegalArgumentException(
String.format(
"The array index is out of range: %d, number of elements: %d.",
index + count, size));
LOG.severe(ex, ex.getMessage());
throw ex;
}
long toIndex = normalisedFromIndex + count;
return Tuple.of((int) normalisedFromIndex, (int) toIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public void close() {

protected SQLException createCoercionException(
int columnIndex, Class<?> targetClass, Exception cause) throws SQLException {
LOG.severe(cause, "Coercion failed");
Comment thread
Neenu1995 marked this conversation as resolved.
checkClosed();
StandardSQLTypeName type;
String typeName;
Expand All @@ -123,8 +124,11 @@ protected SQLException createCoercionException(
type = arrayField.getType().getStandardType();
typeName = type.name();
} else {
throw new SQLException(
"For a nested ResultSet from an Array, columnIndex must be 1 or 2.", cause);
SQLException ex =
new SQLException(
"For a nested ResultSet from an Array, columnIndex must be 1 or 2.", cause);
LOG.severe(ex, "For a nested ResultSet from an Array, columnIndex must be 1 or 2.");
throw ex;
}
} else {
Field field = this.schemaFieldList.get(columnIndex - 1);
Expand All @@ -144,18 +148,25 @@ private StandardSQLTypeName getStandardSQLTypeName(int columnIndex) throws SQLEx
return StandardSQLTypeName.INT64;
} else if (columnIndex == 2) {
if (this.schema == null || this.schema.getFields().isEmpty()) {
throw new SQLException("Schema not available for nested result set.");
SQLException ex = new SQLException("Schema not available for nested result set.");
LOG.severe(ex, "Schema not available for nested result set.");
throw ex;
}
Field arrayField = this.schema.getFields().get(0);
return arrayField.getType().getStandardType();
} else {
throw new SQLException("For a nested ResultSet from an Array, columnIndex must be 1 or 2.");
SQLException ex =
new SQLException("For a nested ResultSet from an Array, columnIndex must be 1 or 2.");
LOG.severe(ex, "For a nested ResultSet from an Array, columnIndex must be 1 or 2.");
throw ex;
}
} else {
if (this.schemaFieldList == null
|| columnIndex > this.schemaFieldList.size()
|| columnIndex < 1) {
throw new SQLException("Invalid column index: " + columnIndex);
SQLException ex = new SQLException("Invalid column index: " + columnIndex);
LOG.severe(ex, "Invalid column index: " + columnIndex);
throw ex;
}
Field field = this.schemaFieldList.get(columnIndex - 1);
return field.getType().getStandardType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,18 @@ abstract class BigQueryBaseStruct implements java.sql.Struct {

@Override
public final String getSQLTypeName() throws SQLException {
LOG.severe(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
throw new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
BigQueryJdbcSqlFeatureNotSupportedException ex =
new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
LOG.severe(ex, CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
throw ex;
}

@Override
public final Object[] getAttributes(Map<String, Class<?>> map) throws SQLException {
LOG.severe(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
throw new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
BigQueryJdbcSqlFeatureNotSupportedException ex =
new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
LOG.severe(ex, CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
throw ex;
}

static boolean isStruct(Field currentSchema) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ else if (referenceQueueJsonRs != null) {
reference.clear();
}
} else {
LOG.severe("Null Reference Queue");
throw new BigQueryJdbcRuntimeException("Null Reference Queue");
BigQueryJdbcRuntimeException ex = new BigQueryJdbcRuntimeException("Null Reference Queue");
LOG.severe(ex, "Null Reference Queue");
throw ex;
}
} catch (InterruptedException ex) {
LOG.severe(ex, "Interrupted in GC daemon task");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2639,6 +2639,7 @@ public ResultSet getPrimaryKeys(String catalog, String schema, String table) thr
String formattedSql = replaceSqlParameters(sql, catalog, schema, table);
return this.statement.executeQuery(formattedSql);
} catch (SQLException e) {
LOG.severe(e, "Error executing getPrimaryKeys");
throw new BigQueryJdbcException(e);
}
}
Expand All @@ -2654,6 +2655,7 @@ public ResultSet getImportedKeys(String catalog, String schema, String table)
String formattedSql = replaceSqlParameters(sql, catalog, schema, table);
return this.statement.executeQuery(formattedSql);
} catch (SQLException e) {
LOG.severe(e, "Error executing getImportedKeys");
throw new BigQueryJdbcException(e);
}
}
Expand All @@ -2669,6 +2671,7 @@ public ResultSet getExportedKeys(String catalog, String schema, String table)
String formattedSql = replaceSqlParameters(sql, catalog, schema, table);
return this.statement.executeQuery(formattedSql);
} catch (SQLException e) {
LOG.severe(e, "Error executing getExportedKeys");
throw new BigQueryJdbcException(e);
}
}
Expand Down Expand Up @@ -2698,6 +2701,7 @@ public ResultSet getCrossReference(
foreignTable);
return this.statement.executeQuery(formattedSql);
} catch (SQLException e) {
LOG.severe(e, "Error executing getCrossReference");
throw new BigQueryJdbcException(e);
}
}
Expand Down Expand Up @@ -5260,16 +5264,18 @@ private void loadDriverVersionProperties() {
if (input == null) {
String errorMessage =
"Could not find dependencies.properties. Driver version information is unavailable.";
LOG.severe(errorMessage);
throw new IllegalStateException(errorMessage);
IllegalStateException ex = new IllegalStateException(errorMessage);
LOG.severe(ex, errorMessage);
throw ex;
}
props.load(input);
String versionString = props.getProperty("version.jdbc");
if (versionString == null || versionString.trim().isEmpty()) {
String errorMessage =
"The property version.jdbc not found or empty in dependencies.properties.";
LOG.severe(errorMessage);
throw new IllegalStateException(errorMessage);
IllegalStateException ex = new IllegalStateException(errorMessage);
LOG.severe(ex, errorMessage);
throw ex;
}
parsedDriverVersion.compareAndSet(null, versionString.trim());
String[] parts = versionString.split("\\.");
Expand All @@ -5287,8 +5293,9 @@ private void loadDriverVersionProperties() {
"Error reading dependencies.properties. Driver version information is"
+ " unavailable. Error: "
+ e.getMessage();
LOG.severe(errorMessage);
throw new IllegalStateException(errorMessage, e);
IllegalStateException ex = new IllegalStateException(errorMessage, e);
LOG.severe(ex, errorMessage);
throw ex;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ public class BigQueryDriver implements Driver {
try {
register();
} catch (SQLException e) {
throw new ExceptionInInitializerError("Registering driver failed: " + e.getMessage());
ExceptionInInitializerError ex =
new ExceptionInInitializerError("Registering driver failed: " + e.getMessage());
LOG.severe(ex, ex.getMessage());
throw ex;
}
LoadBalancerRegistry.getDefaultRegistry().register(new PickFirstLoadBalancerProvider());
}
Expand Down Expand Up @@ -95,8 +98,11 @@ public static BigQueryDriver getRegisteredDriver() throws IllegalStateException
if (isRegistered()) {
return registeredBigqueryJdbcDriver;
}
throw new IllegalStateException(
"Driver is not registered (or it has not been registered using Driver.register() method)");
IllegalStateException ex =
new IllegalStateException(
"Driver is not registered (or it has not been registered using Driver.register() method)");
LOG.severe(ex, ex.getMessage());
throw ex;
}

/**
Expand Down Expand Up @@ -127,6 +133,7 @@ public Connection connect(String url, Properties info) throws SQLException {
try {
BigQueryJdbcUrlUtility.parseUrl(connectionUri);
} catch (BigQueryJdbcRuntimeException e) {
LOG.severe(e, "Failed to parse connection URL");
throw new BigQueryJdbcException(e.getMessage(), e);
}

Expand Down Expand Up @@ -186,7 +193,9 @@ public Connection connect(String url, Properties info) throws SQLException {
public boolean acceptsURL(String url) throws SQLException {
LOG.finest("++enter++");
if (url == null || url.isEmpty()) {
throw new BigQueryJdbcException("Connection URL is null.");
BigQueryJdbcException ex = new BigQueryJdbcException("Connection URL is null.");
LOG.severe(ex, ex.getMessage());
throw ex;
}
return url.startsWith("jdbc:bigquery:");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ static Map<String, String> parseOAuthProperties(DataSource ds, String callerClas
try {
authType = AuthType.fromValue(ds.getOAuthType());
} catch (NumberFormatException exception) {
LOG.severe(exception, OAUTH_TYPE_ERROR_MESSAGE);
throw new IllegalArgumentException(OAUTH_TYPE_ERROR_MESSAGE);
}
oauthProperties.put(BigQueryJdbcUrlUtility.OAUTH_TYPE_PROPERTY_NAME, String.valueOf(authType));
Expand Down Expand Up @@ -458,6 +459,7 @@ private static GoogleCredentials getGoogleUserAccountCredentials(
Matcher m = p.matcher(response);

if (!m.find()) {
LOG.severe("Could not retrieve the code for user auth");
throw new BigQueryJdbcRuntimeException("Could not retrieve the code for user auth");
}
code = m.group();
Expand All @@ -467,6 +469,7 @@ private static GoogleCredentials getGoogleUserAccountCredentials(
socket.close();
serverSocket.close();
} else {
LOG.severe("User auth only supported in desktop environments");
throw new BigQueryJdbcRuntimeException("User auth only supported in desktop environments");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ static Map<String, String> parseProxyProperties(DataSource ds, String callerClas
String proxyPort = ds.getProxyPort();
if (proxyPort != null) {
if (!Pattern.compile(validPortRegex).matcher(proxyPort).find()) {
LOG.severe(
"Illegal port number provided %s. Please provide a valid port number.", proxyPort);
throw new IllegalArgumentException(
String.format(
"Illegal port number provided %s. Please provide a valid port number.", proxyPort));
IllegalArgumentException ex =
new IllegalArgumentException(
String.format(
"Illegal port number provided %s. Please provide a valid port number.",
proxyPort));
LOG.severe(ex, ex.getMessage());
throw ex;
}
proxyProperties.put(BigQueryJdbcUrlUtility.PROXY_PORT_PROPERTY_NAME, proxyPort);
}
Expand All @@ -91,25 +93,34 @@ static Map<String, String> parseProxyProperties(DataSource ds, String callerClas
boolean isMissingProxyHostOrPortWhenProxySet =
(proxyHost == null && proxyPort != null) || (proxyHost != null && proxyPort == null);
if (isMissingProxyHostOrPortWhenProxySet) {
IllegalArgumentException ex =
new IllegalArgumentException(
"Both ProxyHost and ProxyPort parameters need to be specified. No defaulting behavior"
+ " occurs.");
LOG.severe(
ex,
"Both ProxyHost and ProxyPort parameters need to be specified. No defaulting behavior occurs.");
throw new IllegalArgumentException(
"Both ProxyHost and ProxyPort parameters need to be specified. No defaulting behavior"
+ " occurs.");
throw ex;
}
boolean isMissingProxyUidOrPwdWhenAuthSet =
(proxyUid == null && proxyPwd != null) || (proxyUid != null && proxyPwd == null);
if (isMissingProxyUidOrPwdWhenAuthSet) {
LOG.severe("Both ProxyUid and ProxyPwd parameters need to be specified for authentication.");
throw new IllegalArgumentException(
"Both ProxyUid and ProxyPwd parameters need to be specified for authentication.");
IllegalArgumentException ex =
new IllegalArgumentException(
"Both ProxyUid and ProxyPwd parameters need to be specified for authentication.");
LOG.severe(
ex, "Both ProxyUid and ProxyPwd parameters need to be specified for authentication.");
throw ex;
}
boolean isProxyAuthSetWithoutProxySettings = proxyUid != null && proxyHost == null;
if (isProxyAuthSetWithoutProxySettings) {
IllegalArgumentException ex =
new IllegalArgumentException(
"Proxy authentication provided via connection string with no proxy host or port set.");
LOG.severe(
ex,
"Proxy authentication provided via connection string with no proxy host or port set.");
throw new IllegalArgumentException(
"Proxy authentication provided via connection string with no proxy host or port set.");
throw ex;
}
return proxyProperties;
}
Expand Down
Loading
Loading