Skip to content

Conversation

BenWhitehead
Copy link
Collaborator

All Storage and TransferManager instances now have try-with-resource around them.

  • chore: run mvn com.spotify.fmt:fmt-maven-plugin:format

The vast majority of the lines changed in here are whitespace due to additional indentation after using the try-with-resources. I did not change any logic of any of the tests or samples themselves.

@product-auto-label product-auto-label bot added size: l Pull request size is large. api: storage Issues related to the googleapis/java-storage API. samples Issues that are directly related to samples. labels Sep 5, 2025
@blakeli0
Copy link
Contributor

I'm just passing by. One caveat of this is that some customers may copy paste the samples without thinking, which would end up creating one client per request and cause other performance issues. We've seen it in the past and actually plan to add update our samples to include both ways. Because in a typical application, these client are probably not created manually with try-with-resource, but created by frameworks like Spring as a long-lived bean.

@BenWhitehead
Copy link
Collaborator Author

Understood, however I think the thing that is missing from most stuff today is any hint that the client(s) should be closed when you're done with them.

I'd hope that framework maintainers would be able to recognize a try-with-resource and determine how to fit that into the lifecycle of the abstraction they are implementing.

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

Labels

api: storage Issues related to the googleapis/java-storage API. samples Issues that are directly related to samples. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants