Sitelet https://github.com/googleapis/java-storage/issues/839
Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

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

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)

Activity

  1. added
    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.
    on May 20, 2021
  2. self-assigned this
    on Jun 1, 2021
  3. added a commit that references this issue on Jun 1, 2021
    d0f2184
  4. reopened this on Jun 1, 2021
  5. frankyn commented on Jun 1, 2021

    @frankyn
    Contributor

    This is not yet resolved, IIUC, and the change merged is to provide more debugging context. @BenWhitehead is this accurate?

  6. added a commit that references this issue on Jun 1, 2021
  7. BenWhitehead commented on Aug 6, 2021

    @BenWhitehead
    Collaborator

    Received confirmation from the customer they're no longer seeing the error after upgrading to the latest version.

  8. added a commit that references this issue on Sep 28, 2021
    447d35d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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