fix(firestore): rename internal Version class to FirestoreAdminVersion to avoid duplicate class conflict#13397
Conversation
…n to avoid duplicate class conflict
There was a problem hiding this comment.
Code Review
This pull request renames the Version class to FirestoreAdminVersion in the google-cloud-firestore-admin module to prevent naming conflicts, and updates owlbot.py to automate this renaming and class replacement. It also fixes a bug in owlbot.py where an assignment was incorrectly written as a comparison. The review feedback suggests improving owlbot.py by explicitly specifying UTF-8 encoding when opening files to ensure cross-platform compatibility, and using the more idiomatic s.replace method instead of manual file operations to update version references.
| # Replace Version.VERSION with FirestoreAdminVersion.VERSION in FirestoreAdminStubSettings.java | ||
| settings_path = "google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStubSettings.java" | ||
| if os.path.exists(settings_path): | ||
| with open(settings_path, 'r') as f: | ||
| content = f.read() | ||
| content = content.replace("Version.VERSION", "FirestoreAdminVersion.VERSION") | ||
| with open(settings_path, 'w') as f: | ||
| f.write(content) |
There was a problem hiding this comment.
Using s.replace is more idiomatic for owlbot.py scripts and is more robust as it will automatically apply the replacement to any stub settings files in the package (including any new ones added in the future), rather than hardcoding a single file path.
# Replace Version.VERSION with FirestoreAdminVersion.VERSION in stub files
s.replace(
"google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/**/*.java",
"Version.VERSION",
"FirestoreAdminVersion.VERSION",
)724934e to
e749d21
Compare
…admin block in owlbot.py
bom-content-test failed in the releasing PR of java-cloud-bom due to duplicated class error.
This would result in build-time failures in customer's applications if they have static analysis tools enabled.
As a short term fix, replaced the internal Version class in google-cloud-firestore-admin with FirestoreAdminVersion to avoid the error.
In the long term, we should have static checks in this repo to prevent this from happening.