On Fri, Nov 10, 2017 at 3:54 AM, nicolas de loof <[email protected]> wrote: > I'll rewrite configure method as : > > public boolean configure(StaplerRequest req, JSONObject json) throws > FormException { > req.bindJSON(this, json); > save(); > return true; > } > > (by the way, shouldn't this be the default implementation ?)
Maybe. I already did this for `GlobalConfiguration`: https://github.com/jenkinsci/jenkins/pull/2509 > if I UNCHECK the optional property, no "authentication" value > is posted to JSON form, and I don't get SMTPAuthentication reset to null in > my descriptor. Unfortunately your `configure` override must start by setting any optional struct fields to null: https://github.com/jenkinsci/ui-samples-plugin/blob/7d0fe2b32204a7fe0ec6adb6815e65d48b0dd54e/src/main/java/jenkins/plugins/ui_samples/HeteroList.java#L81 > this configuration mechanism isn't atomic, and > there's some possible race condition for related attributes to have > inconsistent values seen from another thread while the configuration is > being changed. It is not a “possible” race condition; it is definitely a race condition. Just how Jenkins works. Anyway this is a change you would apply on Jenkins startup, not while stuff is running, right? > considering recommended and well adopted approach to > retrieve a Descriptor is to use > Jenkins.getInstance.getDescriptor(describable), not referring to some final > static constant Some people (following Kohsuke’s lead) `@Inject` descriptors. > I wonder we could get the Descriptor.configure mechanism to > rely on @DataBoundConstructors just like Describable do. I doubt that could be done compatibly. Would break assumptions deep in `ExtensionList`. Anyway some `Descriptor`s maintain (transient) state, etc. Another style is to avoid `f:optionalProperty` and have an explicit object representing the choice of no authentication, with a no-arg `@DataBoundConstructor` and a `@Symbol`. -- You received this message because you are subscribed to the Google Groups "Jenkins Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr1bGPXiOU6AKwSuVNMuKJmWHtJ0ZoahrKoKdDQigJdi_g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
