GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — storage: read blob in chunk will get exception when reach the end the blob · Issue #723 · googleapis/google-cloud-java

storage: read blob in chunk will get exception when reach the end the blob #723

New issue
Copy link
New issue
Copy link
Closed
Closed
storage: read blob in chunk will get exception when reach the end the blob#723
Copy link
Assignees
mziccard

Description

@sudison
sudison
opened on Mar 7, 2016
Issue body actions

Following code is used to read blob chunk by chunk:

try (ReadChannel reader = blob.reader()) {
  WritableByteChannel channel = Channels.newChannel(outputStream);
  ByteBuffer bytes = ByteBuffer.allocate(64 * 1024);
  while (reader.read(bytes) > 0) {
    bytes.flip();
    channel.write(bytes);
    bytes.clear();
  }
}

reader.read() will throw exception:

com.google.gcloud.storage.StorageException: java.lang.NullPointerException

at com.google.gcloud.storage.StorageException.translateAndThrow(StorageException.java:74)
at com.google.gcloud.storage.BlobReadChannel.read(BlobReadChannel.java:159)

The root cause is, reader is blindly reading chunks from cloud storage, if it reaches beyond the end of the blob, then cloud storage will throw an error: 416 Requested range not satisfiable.

Activity

Next
  1. mziccard commented on Mar 7, 2016

    @mziccard
    mziccard
    on Mar 7, 2016
    Contributor
    More actions

    Hey @sudison thanks for the report. Unfortunately I did not manage to reproduce the error. Which version of gcloud-java are you using? How big is the blob you are trying to read?

    Thanks

  2. sudison commented on Mar 7, 2016

    @sudison
    sudison
    on Mar 7, 2016
    Author
    More actions

    blob size is 2 x 1024 x 1024, gcloud version is 0.1.4

  3. aozarov commented on Mar 7, 2016

    @aozarov
    aozarov
    on Mar 7, 2016
    Contributor
    More actions

    @sudison Thanks, I can reproduce that and will fix that together with #720

  4. aozarov
    added a commit that references this issue on Mar 8, 2016

    Fix test and issue googleapis#723

    36ebabd
  5. aozarov commented on Mar 8, 2016

    @aozarov
    aozarov
    on Mar 8, 2016
    Contributor
    More actions

    #725 should fix both issues (waiting for a reviewer before it can get merged).

  6. mziccard commented on Mar 8, 2016

    @mziccard
    mziccard
    on Mar 8, 2016
    Contributor
    More actions

    @sudison We just merged #725 so this should be fixed in master now. We will release a new version of gcloud-java soon to make this fix available through in maven. I'll write here as soon as we release the new artifact.

  7. mziccard
    closed this as completedon Mar 8, 2016
  8. sudison commented on Mar 8, 2016

    @sudison
    sudison
    on Mar 8, 2016
    Author
    More actions

    Thanks for the quick fixes. Tested locally, it works.

  9. mziccard commented on Mar 8, 2016

    @mziccard
    mziccard
    on Mar 8, 2016
    Contributor
    More actions

    @sudison Thanks to you for reporting the issues! Version 0.1.5 is out now and includes the fixes!

  10. JustinBeckwith
    assigned
    mziccard
    on Feb 1, 2021
  11. github-actions
    added 3 commits that reference this issue on Jun 29, 2022

    deps: update actions/setup-java action to v3 (googleapis#723)

    b89f6b5

    chore(main): release 1.2.4 (googleapis#726)

    03d6331

    chore(deps): update dependency com.google.cloud:google-cloud-billingb…

    2b5765d
  12. github-actions
    added 2 commits that reference this issue on Jul 20, 2022

    build(deps): update dependency org.apache.maven.plugins:maven-deploy-…

    65da333

    deps: update dependency com.google.protobuf:protobuf-java-util to v3.…

    0df1911
  13. 14 remaining items

  14. github-actions
    added 3 commits that reference this issue on Oct 5, 2022

    chore(main): release 2.3.5-SNAPSHOT (googleapis#723)

    fab9ac1

    chore(main): release 0.9.6-SNAPSHOT (googleapis#723)

    5431661

    chore(main): release 0.123.18-SNAPSHOT (#723)

    514187c
  15. suztomo
    added a commit that references this issue on Feb 1, 2023

    chore: update dependencies for regapic (#1467) (#723)

    be8b69d
  16. meltsufin
    added a commit that references this issue on Dec 22, 2025

    chore: release 3.4.0 (#723)

    80e79c7
  17. chingor13
    added 3 commits that reference this issue on Jan 6, 2026

    deps: update dependency com.google.cloud:google-cloud-shared-dependen…

    fd500fe

    chore(main): release 0.122.17 (#724)

    92490a6

    chore(main): release 0.124.0 (#770)

    b5bf336
  18. chingor13
    added 2 commits that reference this issue on Jan 22, 2026

    fix(java): rename test to be picked up by native profile (#723)

    3a30e75

    chore(main): release 2.5.0 (#729)

    c04b37e
  19. suztomo
    added a commit that references this issue on Mar 11, 2026

    chore: release 3.4.0 (googleapis#723)

    5467ae2
  20. suztomo
    added a commit that references this issue on Mar 23, 2026

    test(deps): update dependency org.mockito:mockito-core to v4.3.0 (goo…

    d9530fe
  21. meltsufin
    added 2 commits that reference this issue on Apr 29, 2026

    chore(deps): update dependency com.google.cloud:google-cloud-pubsub t…

    9b2b8f0

    chore(deps): update dependency com.google.cloud:google-cloud-pubsub t…

    96aca7e
  22. benjaminp
    added a commit that references this issue on Jul 13, 2026

    chore(deps): update dependency com.google.cloud:libraries-bom to v20 (g…

    24a18d4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @mziccard
    mziccard

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.