Commit dcc2a68
authored
fix(bigquery): prevent NullPointerException in OTel tracing when JobId is null (#13301)
b/517929704
This PR addresses a `NullPointerException` that occurs in the BigQuery
client library when OpenTelemetry tracing is enabled and operations are
performed on jobs that do not have a client-assigned `JobId` at the
start of the call.
A notable case where this happens is during dry-run queries (often used
to determine statement type or fetch statistics) where
`JobInfo.getJobId()` returns null. The OTel instrumentation was
attempting to extract attributes from the `JobId` without checking for
nullability.
**Changes:**
* Added null checks before calling `JobId.getOtelAttributes()` in
`BigQueryImpl.create(JobInfo)` (line 455).
* Added null checks before calling `JobId.getOtelAttributes()` in
`BigQueryImpl.getQueryResults(JobId)` (line 2128).
* These changes align with the safe-check pattern already implemented in
`BigQueryImpl.queryWithTimeout` (line 2075).1 parent 6710ae0 commit dcc2a68
1 file changed
Lines changed: 6 additions & 3 deletions
File tree
- java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
452 | 452 | | |
453 | 453 | | |
454 | 454 | | |
455 | | - | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
456 | 459 | | |
457 | 460 | | |
458 | 461 | | |
| |||
2072 | 2075 | | |
2073 | 2076 | | |
2074 | 2077 | | |
2075 | | - | |
| 2078 | + | |
2076 | 2079 | | |
2077 | 2080 | | |
2078 | 2081 | | |
| |||
2125 | 2128 | | |
2126 | 2129 | | |
2127 | 2130 | | |
2128 | | - | |
| 2131 | + | |
2129 | 2132 | | |
2130 | 2133 | | |
2131 | 2134 | | |
| |||
0 commit comments