google-cloud-eclipse icon indicating copy to clipboard operation
google-cloud-eclipse copied to clipboard

Consider safer pattern to retrieve deploy preferences during deploy

Open chanseokoh opened this issue 8 years ago • 1 comments

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, DeployPreferences is 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 DeployPreferences may 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 by new 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.

chanseokoh avatar Sep 22 '17 18:09 chanseokoh