KEMBAR78
Storage: `BlobWriteChannel` generates `NullPointerException` in some failure cases (e.g. networking issues) · Issue #839 · googleapis/java-storage · GitHub
Skip to content

Storage: BlobWriteChannel generates NullPointerException in some failure cases (e.g. networking issues) #839

@AdamBSteele

Description

@AdamBSteele

Problem

BlobWriteChannel generates NullPointerException in some failure cases (e.g. due to a networking error).
Specifically, BlobWriteChannel:176 might retrieve null StorageObject which causes BlobWriteChannel:180 to generate NullPointerException when trying to dereference it.

This unhandled exception makes it difficult to clearly resolve issues and resume any impacted operations/scripts. As an engineer/on call, I want logs to be more clear (unnecessary exceptions not to be thrown at all if that's possible), so I can get issues resolved faster with less confusion and spend less time on manual workarounds.

Environment details

  1. Specify the API at the beginning of the title. For example, "BigQuery: ...").
    General, Core, and Other are also allowed as types
  2. OS type and version:
  3. Java version:
  4. storage version(s): 1.113.14 and 1.114.0.

Steps to reproduce

  1. Simulate faulty network (dropped packets ~35%, less works too, but takes more time to catch)
  2. Call BlobWriteChannel
  3. See NullPointerException

Stack trace

java.lang.RuntimeException: java.util.concurrent.ExecutionException: ... omitted ...
Caused by: ...: Unable to write ...
... omitted ...
Caused by: java.lang.RuntimeException: Unable to write ... to gs://...
... omitted ...
... 10 more
Caused by: com.google.cloud.storage.StorageException: java.lang.NullPointerException
at com.google.cloud.storage.StorageException.translateAndThrow(StorageException.java:81)
at com.google.cloud.storage.BlobWriteChannel.flushBuffer(BlobWriteChannel.java:212)
at com.google.cloud.BaseWriteChannel.close(BaseWriteChannel.java:151)
at java.base/java.nio.channels.Channels$1.close(Channels.java:177)
at java.base/java.io.FilterOutputStream.close(FilterOutputStream.java:188)
at java.base/java.io.FilterOutputStream.close(FilterOutputStream.java:188)
at org.apache.avro.file.DataFileWriter.close(DataFileWriter.java:461)
... omitted ...
... 14 more
Caused by: java.lang.NullPointerException
at com.google.cloud.storage.BlobWriteChannel$1.run(BlobWriteChannel.java:180)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at com.google.api.gax.retrying.DirectRetryingExecutor.submit(DirectRetryingExecutor.java:105)
at com.google.cloud.RetryHelper.run(RetryHelper.java:76)
at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:50)
at com.google.cloud.storage.BlobWriteChannel.flushBuffer(BlobWriteChannel.java:157)

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the googleapis/java-storage API.priority: p2Moderately-important priority. Fix may not be included in next release.status: investigatingThe issue is under investigation, which is determined to be non-trivial.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions