GeezerVison is showing github.com (truncated) — Fix Files.walk behavior by jean-philippe-martin · Pull Request #2124 · googleapis/google-cloud-java
Conversation
Java's Files.walk() ends up in an infinite loop when iterating
over files on GCS because the iterator returns the directory
itself as the first result, so Files.walk() tries to cd there
and we're stuck.
The fix is to check for that path and not return it.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Java's Files.walk() ends up in an infinite loop when iterating
over files on GCS because the iterator returns the directory
itself as the first result, so Files.walk() tries to cd there
and we're stuck.
The fix is to check for that path and not return it.
|

Changes Unknown when pulling 9c8e6a2 on jean-philippe-martin:jp_fix_file_walker into ** on GoogleCloudPlatform:master**.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Travis error was a transient, nothing to do with the code:
The command "git clone -b travis `git config --get remote.origin.url` target/travis" failed and exited with 128 during .
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|

Changes Unknown when pulling 15c66b7 on jean-philippe-martin:jp_fix_file_walker into ** on GoogleCloudPlatform:master**.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@jean-philippe-martin Thanks for fixing this. It would have been better if this code could include the original prefix in the returned tuple, so the caller could easily remove the prefix (i.e. the start directory) from the combined list of items and prefixes.
@garrettjonesgoogle Could you please also take a look ?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@neozwu Are you suggesting changing the StorageRpc interface ? That would impact a lot of code I'm not very familiar with, and it's a public interface so clients might rely on it. I agree that it would be nice if it had been that way from the start and perhaps that's what you're saying?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@jean-philippe-martin ahh, no I'm not suggesting to do any change like that - that would be too many breaking changes. Sorry for the confusion. I just meant to mention that it is a potential thing to improve when/if we rewrite the whole thing.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
ah ok @neozwu, that makes sense now! Thank you!
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@garrettjonesgoogle @neozwu Anything more need to be done to get this one merged? This is a pretty serious bug that manifests itself in hard lockups on our end (as a client of google-cloud-java), so we'd be very glad to see this fixed in the next release.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
suztomo
pushed a commit
to suztomo/google-cloud-java
that referenced
this pull request
Mar 23, 2026
suztomo
pushed a commit
that referenced
this pull request
Mar 30, 2026
* Fix Files.walk behavior
Java's Files.walk() ends up in an infinite loop when iterating
over files on GCS because the iterator returns the directory
itself as the first result, so Files.walk() tries to cd there
and we're stuck.
The fix is to check for that path and not return it.
* no-op commit to force Travis to retry
lqiu96
pushed a commit
that referenced
this pull request
Apr 1, 2026
* Fix Files.walk behavior
Java's Files.walk() ends up in an infinite loop when iterating
over files on GCS because the iterator returns the directory
itself as the first result, so Files.walk() tries to cd there
and we're stuck.
The fix is to check for that path and not return it.
* no-op commit to force Travis to retry
|