Skip to content

Commit d6e2653

Browse files
authored
Merge branch 'main' into check-showcase-test
2 parents 4749d02 + fac4092 commit d6e2653

79 files changed

Lines changed: 461 additions & 2872 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

generation_config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,6 @@ libraries:
15581558
api_id: managedidentities.googleapis.com
15591559
GAPICs:
15601560
- proto_path: google/cloud/managedidentities/v1
1561-
- proto_path: google/cloud/managedidentities/v1beta1
15621561
- api_shortname: managedkafka
15631562
name_pretty: Managed Service for Apache Kafka
15641563
product_documentation: https://cloud.google.com/managed-kafka

java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryBaseArray.java

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,28 +71,36 @@ public final int getBaseType() {
7171

7272
@Override
7373
public final Object getArray(Map<String, Class<?>> map) throws SQLException {
74-
LOG.severe(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
75-
throw new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
74+
BigQueryJdbcSqlFeatureNotSupportedException ex =
75+
new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
76+
LOG.severe(ex, CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
77+
throw ex;
7678
}
7779

7880
@Override
7981
public final Object getArray(long index, int count, Map<String, Class<?>> map)
8082
throws SQLException {
81-
LOG.severe(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
82-
throw new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
83+
BigQueryJdbcSqlFeatureNotSupportedException ex =
84+
new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
85+
LOG.severe(ex, CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
86+
throw ex;
8387
}
8488

8589
@Override
8690
public final ResultSet getResultSet(Map<String, Class<?>> map) throws SQLException {
87-
LOG.severe(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
88-
throw new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
91+
BigQueryJdbcSqlFeatureNotSupportedException ex =
92+
new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
93+
LOG.severe(ex, CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
94+
throw ex;
8995
}
9096

9197
@Override
9298
public final ResultSet getResultSet(long index, int count, Map<String, Class<?>> map)
9399
throws SQLException {
94-
LOG.severe(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
95-
throw new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
100+
BigQueryJdbcSqlFeatureNotSupportedException ex =
101+
new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
102+
LOG.severe(ex, CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
103+
throw ex;
96104
}
97105

98106
protected Object getArrayInternal(int fromIndex, int toIndexExclusive) {
@@ -110,8 +118,9 @@ protected Object getArrayInternal(int fromIndex, int toIndexExclusive) {
110118
protected void ensureValid() throws IllegalStateException {
111119
LOG.finest("++enter++");
112120
if (!this.valid) {
113-
LOG.severe(INVALID_ARRAY);
114-
throw new IllegalStateException(INVALID_ARRAY);
121+
IllegalStateException ex = new IllegalStateException(INVALID_ARRAY);
122+
LOG.severe(ex, INVALID_ARRAY);
123+
throw ex;
115124
}
116125
}
117126

@@ -132,11 +141,13 @@ protected Tuple<Integer, Integer> createRange(long index, int count, int size)
132141
// jdbc array follows 1 based array indexing
133142
long normalisedFromIndex = index - 1;
134143
if (normalisedFromIndex + count > size) {
135-
LOG.severe(
136-
"The array index is out of range: %d, number of elements: %d.", index + count, size);
137-
throw new IllegalArgumentException(
138-
String.format(
139-
"The array index is out of range: %d, number of elements: %d.", index + count, size));
144+
IllegalArgumentException ex =
145+
new IllegalArgumentException(
146+
String.format(
147+
"The array index is out of range: %d, number of elements: %d.",
148+
index + count, size));
149+
LOG.severe(ex, ex.getMessage());
150+
throw ex;
140151
}
141152
long toIndex = normalisedFromIndex + count;
142153
return Tuple.of((int) normalisedFromIndex, (int) toIndex);

java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryBaseResultSet.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public void close() {
109109

110110
protected SQLException createCoercionException(
111111
int columnIndex, Class<?> targetClass, Exception cause) throws SQLException {
112+
LOG.severe(cause, "Coercion failed");
112113
checkClosed();
113114
StandardSQLTypeName type;
114115
String typeName;
@@ -123,8 +124,11 @@ protected SQLException createCoercionException(
123124
type = arrayField.getType().getStandardType();
124125
typeName = type.name();
125126
} else {
126-
throw new SQLException(
127-
"For a nested ResultSet from an Array, columnIndex must be 1 or 2.", cause);
127+
SQLException ex =
128+
new SQLException(
129+
"For a nested ResultSet from an Array, columnIndex must be 1 or 2.", cause);
130+
LOG.severe(ex, "For a nested ResultSet from an Array, columnIndex must be 1 or 2.");
131+
throw ex;
128132
}
129133
} else {
130134
Field field = this.schemaFieldList.get(columnIndex - 1);
@@ -144,18 +148,25 @@ private StandardSQLTypeName getStandardSQLTypeName(int columnIndex) throws SQLEx
144148
return StandardSQLTypeName.INT64;
145149
} else if (columnIndex == 2) {
146150
if (this.schema == null || this.schema.getFields().isEmpty()) {
147-
throw new SQLException("Schema not available for nested result set.");
151+
SQLException ex = new SQLException("Schema not available for nested result set.");
152+
LOG.severe(ex, "Schema not available for nested result set.");
153+
throw ex;
148154
}
149155
Field arrayField = this.schema.getFields().get(0);
150156
return arrayField.getType().getStandardType();
151157
} else {
152-
throw new SQLException("For a nested ResultSet from an Array, columnIndex must be 1 or 2.");
158+
SQLException ex =
159+
new SQLException("For a nested ResultSet from an Array, columnIndex must be 1 or 2.");
160+
LOG.severe(ex, "For a nested ResultSet from an Array, columnIndex must be 1 or 2.");
161+
throw ex;
153162
}
154163
} else {
155164
if (this.schemaFieldList == null
156165
|| columnIndex > this.schemaFieldList.size()
157166
|| columnIndex < 1) {
158-
throw new SQLException("Invalid column index: " + columnIndex);
167+
SQLException ex = new SQLException("Invalid column index: " + columnIndex);
168+
LOG.severe(ex, "Invalid column index: " + columnIndex);
169+
throw ex;
159170
}
160171
Field field = this.schemaFieldList.get(columnIndex - 1);
161172
return field.getType().getStandardType();

java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryBaseStruct.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,18 @@ abstract class BigQueryBaseStruct implements java.sql.Struct {
4242

4343
@Override
4444
public final String getSQLTypeName() throws SQLException {
45-
LOG.severe(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
46-
throw new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
45+
BigQueryJdbcSqlFeatureNotSupportedException ex =
46+
new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
47+
LOG.severe(ex, CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
48+
throw ex;
4749
}
4850

4951
@Override
5052
public final Object[] getAttributes(Map<String, Class<?>> map) throws SQLException {
51-
LOG.severe(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
52-
throw new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
53+
BigQueryJdbcSqlFeatureNotSupportedException ex =
54+
new BigQueryJdbcSqlFeatureNotSupportedException(CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
55+
LOG.severe(ex, CUSTOMER_TYPE_MAPPING_NOT_SUPPORTED);
56+
throw ex;
5357
}
5458

5559
static boolean isStruct(Field currentSchema) {

java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDaemonPollingTask.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,9 @@ else if (referenceQueueJsonRs != null) {
113113
reference.clear();
114114
}
115115
} else {
116-
LOG.severe("Null Reference Queue");
117-
throw new BigQueryJdbcRuntimeException("Null Reference Queue");
116+
BigQueryJdbcRuntimeException ex = new BigQueryJdbcRuntimeException("Null Reference Queue");
117+
LOG.severe(ex, "Null Reference Queue");
118+
throw ex;
118119
}
119120
} catch (InterruptedException ex) {
120121
LOG.severe(ex, "Interrupted in GC daemon task");

java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDatabaseMetaData.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2639,6 +2639,7 @@ public ResultSet getPrimaryKeys(String catalog, String schema, String table) thr
26392639
String formattedSql = replaceSqlParameters(sql, catalog, schema, table);
26402640
return this.statement.executeQuery(formattedSql);
26412641
} catch (SQLException e) {
2642+
LOG.severe(e, "Error executing getPrimaryKeys");
26422643
throw new BigQueryJdbcException(e);
26432644
}
26442645
}
@@ -2654,6 +2655,7 @@ public ResultSet getImportedKeys(String catalog, String schema, String table)
26542655
String formattedSql = replaceSqlParameters(sql, catalog, schema, table);
26552656
return this.statement.executeQuery(formattedSql);
26562657
} catch (SQLException e) {
2658+
LOG.severe(e, "Error executing getImportedKeys");
26572659
throw new BigQueryJdbcException(e);
26582660
}
26592661
}
@@ -2669,6 +2671,7 @@ public ResultSet getExportedKeys(String catalog, String schema, String table)
26692671
String formattedSql = replaceSqlParameters(sql, catalog, schema, table);
26702672
return this.statement.executeQuery(formattedSql);
26712673
} catch (SQLException e) {
2674+
LOG.severe(e, "Error executing getExportedKeys");
26722675
throw new BigQueryJdbcException(e);
26732676
}
26742677
}
@@ -2698,6 +2701,7 @@ public ResultSet getCrossReference(
26982701
foreignTable);
26992702
return this.statement.executeQuery(formattedSql);
27002703
} catch (SQLException e) {
2704+
LOG.severe(e, "Error executing getCrossReference");
27012705
throw new BigQueryJdbcException(e);
27022706
}
27032707
}
@@ -5260,16 +5264,18 @@ private void loadDriverVersionProperties() {
52605264
if (input == null) {
52615265
String errorMessage =
52625266
"Could not find dependencies.properties. Driver version information is unavailable.";
5263-
LOG.severe(errorMessage);
5264-
throw new IllegalStateException(errorMessage);
5267+
IllegalStateException ex = new IllegalStateException(errorMessage);
5268+
LOG.severe(ex, errorMessage);
5269+
throw ex;
52655270
}
52665271
props.load(input);
52675272
String versionString = props.getProperty("version.jdbc");
52685273
if (versionString == null || versionString.trim().isEmpty()) {
52695274
String errorMessage =
52705275
"The property version.jdbc not found or empty in dependencies.properties.";
5271-
LOG.severe(errorMessage);
5272-
throw new IllegalStateException(errorMessage);
5276+
IllegalStateException ex = new IllegalStateException(errorMessage);
5277+
LOG.severe(ex, errorMessage);
5278+
throw ex;
52735279
}
52745280
parsedDriverVersion.compareAndSet(null, versionString.trim());
52755281
String[] parts = versionString.split("\\.");
@@ -5287,8 +5293,9 @@ private void loadDriverVersionProperties() {
52875293
"Error reading dependencies.properties. Driver version information is"
52885294
+ " unavailable. Error: "
52895295
+ e.getMessage();
5290-
LOG.severe(errorMessage);
5291-
throw new IllegalStateException(errorMessage, e);
5296+
IllegalStateException ex = new IllegalStateException(errorMessage, e);
5297+
LOG.severe(ex, errorMessage);
5298+
throw ex;
52925299
}
52935300
}
52945301
}

java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDriver.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ public class BigQueryDriver implements Driver {
6464
try {
6565
register();
6666
} catch (SQLException e) {
67-
throw new ExceptionInInitializerError("Registering driver failed: " + e.getMessage());
67+
ExceptionInInitializerError ex =
68+
new ExceptionInInitializerError("Registering driver failed: " + e.getMessage());
69+
LOG.severe(ex, ex.getMessage());
70+
throw ex;
6871
}
6972
LoadBalancerRegistry.getDefaultRegistry().register(new PickFirstLoadBalancerProvider());
7073
}
@@ -95,8 +98,11 @@ public static BigQueryDriver getRegisteredDriver() throws IllegalStateException
9598
if (isRegistered()) {
9699
return registeredBigqueryJdbcDriver;
97100
}
98-
throw new IllegalStateException(
99-
"Driver is not registered (or it has not been registered using Driver.register() method)");
101+
IllegalStateException ex =
102+
new IllegalStateException(
103+
"Driver is not registered (or it has not been registered using Driver.register() method)");
104+
LOG.severe(ex, ex.getMessage());
105+
throw ex;
100106
}
101107

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

@@ -186,7 +193,9 @@ public Connection connect(String url, Properties info) throws SQLException {
186193
public boolean acceptsURL(String url) throws SQLException {
187194
LOG.finest("++enter++");
188195
if (url == null || url.isEmpty()) {
189-
throw new BigQueryJdbcException("Connection URL is null.");
196+
BigQueryJdbcException ex = new BigQueryJdbcException("Connection URL is null.");
197+
LOG.severe(ex, ex.getMessage());
198+
throw ex;
190199
}
191200
return url.startsWith("jdbc:bigquery:");
192201
}

java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcMdc.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* Allocates a dedicated, independent InheritableThreadLocal object per concrete BigQueryConnection
2525
* instance.
2626
*/
27-
public class BigQueryJdbcMdc {
27+
class BigQueryJdbcMdc {
2828
private static final AtomicLong nextId = new AtomicLong(1);
2929
private static final ConcurrentHashMap<BigQueryConnection, InheritableThreadLocal<String>>
3030
instanceLocals = new ConcurrentHashMap<>();
@@ -35,7 +35,7 @@ public class BigQueryJdbcMdc {
3535
private static final InheritableThreadLocal<String> currentConnectionId =
3636
new InheritableThreadLocal<>();
3737

38-
public static void registerInstance(BigQueryConnection connection, String id) {
38+
static void registerInstance(BigQueryConnection connection, String id) {
3939
if (connection != null) {
4040
String cleanId =
4141
instanceIds.computeIfAbsent(
@@ -56,12 +56,12 @@ public static void registerInstance(BigQueryConnection connection, String id) {
5656
/**
5757
* Returns the connection ID carried by any registered active connection on the current thread.
5858
*/
59-
public static String getConnectionId() {
59+
static String getConnectionId() {
6060
return currentConnectionId.get();
6161
}
6262

6363
/** Clears the connection ID context from all active connection contexts on the current thread. */
64-
public static void removeInstance(BigQueryConnection connection) {
64+
static void removeInstance(BigQueryConnection connection) {
6565
if (connection != null) {
6666
InheritableThreadLocal<String> local = instanceLocals.remove(connection);
6767
if (local != null) {
@@ -71,7 +71,7 @@ public static void removeInstance(BigQueryConnection connection) {
7171
}
7272
}
7373

74-
public static void clear() {
74+
static void clear() {
7575
currentConnectionId.remove();
7676
for (InheritableThreadLocal<String> local : instanceLocals.values()) {
7777
local.remove();

java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcOAuthUtility.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ static Map<String, String> parseOAuthProperties(DataSource ds, String callerClas
121121
try {
122122
authType = AuthType.fromValue(ds.getOAuthType());
123123
} catch (NumberFormatException exception) {
124+
LOG.severe(exception, OAUTH_TYPE_ERROR_MESSAGE);
124125
throw new IllegalArgumentException(OAUTH_TYPE_ERROR_MESSAGE);
125126
}
126127
oauthProperties.put(BigQueryJdbcUrlUtility.OAUTH_TYPE_PROPERTY_NAME, String.valueOf(authType));
@@ -458,6 +459,7 @@ private static GoogleCredentials getGoogleUserAccountCredentials(
458459
Matcher m = p.matcher(response);
459460

460461
if (!m.find()) {
462+
LOG.severe("Could not retrieve the code for user auth");
461463
throw new BigQueryJdbcRuntimeException("Could not retrieve the code for user auth");
462464
}
463465
code = m.group();
@@ -467,6 +469,7 @@ private static GoogleCredentials getGoogleUserAccountCredentials(
467469
socket.close();
468470
serverSocket.close();
469471
} else {
472+
LOG.severe("User auth only supported in desktop environments");
470473
throw new BigQueryJdbcRuntimeException("User auth only supported in desktop environments");
471474
}
472475

0 commit comments

Comments
 (0)