New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: make CloudStorageFileSystem#forBucket thread safe #719
Conversation
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.
Should probably get a java person to approve this as well, but... really nice!
@Override | ||
public int hashCode() { | ||
return Objects.hash(cloudStorageConfiguration, storageOptions); | ||
} |
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.
These overrides of equals
and hashCode
remind me of Brian's comment (2) in #691 (comment) - is this now ok here because we're no longer looking up via HashMap
(in which case is the override still necessary?) Or are we now waiting until after initialization before caching? Or is Brian's comment still potentially a problem?
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.
The .equals
from that comment was comparing instances of CloudStorageFileSystemProvider
which aren't immutable. Here we're holding on to CloudStorageConfig
which is immutable via AutoValue and a StorageOptions
which has a stable hashCode & equals which don't include transient state. So in this case, we're only keying off the config none of the running state.
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.
Great, thanks! Looks good to me!
Thanks for coming up with a fix so quickly! Just one comment about overriding the |
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.
Thanks @BenWhitehead! LGTM, added a few request for changes. This follows what we discussed earlier this week.
...o/src/test/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystemProviderTest.java
Outdated
Show resolved
Hide resolved
google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystem.java
Outdated
Show resolved
Hide resolved
google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageFileSystem.java
Outdated
Show resolved
Hide resolved
mistakenly included test in Provider test even though it doesn't do anything with the provider api
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.
LGTM, 🚢
Replace manual attempt at caching via a HashMap with a guava Cache.
Fix #691
Fix #698