BigQuery: create() throws NullPointerException on a duplicate job id outside the US multi-region (java-bigquery#3034 not fixed by #3035)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Inizia in java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java intorno alle righe 609–611, quindi confronta il ramo con ID fisso con la gestione vicina di null per idRandom. Esamina testCreateJobTryGetNotRandom e aggiungi la copertura per un nuovo recupero con null; il lavoro è completo quando un duplicato regionale produce l’errore originale Already Exists invece di una NullPointerException.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Environment details
- API: BigQuery (
java-bigquery) - OS type and version: macOS 15 / Linux (not OS-specific)
- Java version: 17
- Version: google-cloud-bigquery 2.68.0, and present on current
main
(java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java
lines 609–611)
Summary
BigQuery.create(JobInfo) with an explicit job id throws
NullPointerException: Cannot invoke "com.google.cloud.bigquery.Job.getStatistics()" because "job" is null
when the id already exists and the job lives outside the US multi-region while the JobId carries
no location — masking the real Already Exists: Job project:location.id error.
This is the failure googleapis/java-bigquery#3034 reported. That issue was closed by
googleapis/java-bigquery#3035, which does not cover this path:
- #3035's production change narrows the re-fetch from
getJob(jobId)to
getJob(jobId, JobOption.fields(JobField.STATISTICS)). Narrowing the requested fields cannot
turn a null return into a job, and #3034's stack trace shows the receiverjobitself was null. - #3035's added test (
testCreateJobTryGetNotRandom) mocks the RPCgetJobreturning a job,
so only the found-job path is covered; the null return has no test.
The NPE therefore still reproduces, deterministically, on 2.68.0 — which contains #3035's change.
Root cause
jobs.get resolves a JobId that names no location against the US multi-region only. When the
duplicated job's location was inferred from the statement (a query or load touching a regional
dataset), the duplicate-id handler's re-fetch misses it, getJob returns null, and
job.getStatistics() throws. The idRandom branch a few lines below already handles exactly this
case with if (job == null) { throw createException; }; the fixed-id branch lacks the same guard.
Steps to reproduce
Run the code below against any project with a dataset outside the US multi-region (reproduced
against a us-central1 dataset). No location is set anywhere; the region comes from the query.
BigQuery bq = BigQueryOptions.newBuilder().setProjectId(project).build().getService();
String sql = "SELECT COUNT(*) FROM `" + project + "." + regionalDataset + ".INFORMATION_SCHEMA.TABLES`";
String id = "npe_repro_" + System.currentTimeMillis();
bq.create(JobInfo.of(JobId.newBuilder().setProject(project).setJob(id).build(),
QueryJobConfiguration.of(sql))); // ok — server infers us-central1
bq.create(JobInfo.of(JobId.newBuilder().setProject(project).setJob(id).build(),
QueryJobConfiguration.of(sql))); // NullPointerException
Control arm: setting the location on the second create's JobId makes the handler find the job
and return it — the intended duplicate-id behaviour — which isolates the defect to the
location-less re-fetch.
Stack trace
java.lang.NullPointerException: Cannot invoke "com.google.cloud.bigquery.Job.getStatistics()" because "job" is null
at com.google.cloud.bigquery.BigQueryImpl.create(BigQueryImpl.java:611)
at com.google.cloud.bigquery.BigQueryImpl.create(BigQueryImpl.java:511)
Expected behaviour and fix
When the re-fetch returns null, fall through to the original exception, as the idRandom branch
does. Verified against BigQuery with the guard patched in: the NPE becomes
BigQueryException: Already Exists: Job flink-gcp:us-central1.npe_repro_a_…, whose message names
the job's actual location. I can send the PR.
- Lingua principale
- Java
- Stelle
- 2.1k
- Fork
- 1.2k
- Merge medio
- 2g 12h
- PR unite (30g)
- 157
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di googleapis/google-cloud-java
-
priority: p3 type: bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 94/100
googleapis/google-cloud-java#14572 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[java-firestore] CustomClassMapper.convertBigDecimal calls .abs() on Double, unintentionally flipping negative values to positiveForse già presa @wu-hui l’ha presa 3 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
googleapis/google-cloud-java#14533 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
googleapis/google-cloud-java#14132 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
priority: p2 type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
googleapis/google-cloud-java#13255 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
priority: p3
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
googleapis/google-cloud-java#13032 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di googleapis/google-cloud-java
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
grimmory-tools/grimmory#2850 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
aoqia194/leaf-loader#19 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
apache/streampark#4521 ·
-
Update license yearAperta0 - Backlog 1 - Ready documentation good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100