google-cloud-eclipse
google-cloud-eclipse copied to clipboard
Consider safer pattern to retrieve deploy preferences during deploy
The DeployPreferences() class is for saving/loading (App Engine standard) deploy parameters (such as a GCP project, a Google account, etc) to/from user preferences. As long as we have an IProject ref, we can conveniently retrieve such deploy preferences anywhere at any point by new DeployPreferences(IProject). We do call this constructor to get values during deploy in a couple places. We don't have any problem currently as we do things right, but the current implementation has a potential risk:
- At the language level,
DeployPreferencesis mutable; you might get a different value later if someone changes the value somehow (which isn't currently the case) in the process of deploying. - Although this isn't currently the case, the implementation of
DeployPreferencesmay change in the future in a way that getting values always returns most-up-to-date preferences values (e.g., users updated the preferences while a deploy is in progress) rather than the values at the time when the instance is constructed bynew DeployPreferences(IProject).
So, for future safety, I think it is better to explicitly take an immutable snapshot of the preferences before launching a deploy job and passing the snapshot.