On 7 August 2014 15:26, Jesse Glick <[email protected]> wrote: > On Thu, Jul 31, 2014 at 5:47 AM, <[email protected]> wrote: > > 1. add removed fields and mark them as transient > > If you mark them transient, they will not even be deserialized. (You > might expect this to only prevent them from being *serialized* but it > actually does both.) So you have to keep those fields nontransient, > just @Deprecated. >
Are you sure about that? Unless I misunderstand the context in which you are making your statement, previously non-transient fields will be deserialized into the evolved classes transient version (which is how the readResolve object can see them) > > Tip: for primitive-valued fields, this will mean they stay in the > config.xml with default values like 0/false. The workaround is to > change the type to wrappers like Boolean or Integer; when the value is > set to null during migration, the field will disappear from config.xml > like you would want. > > > 2. register static method with @Initializer(after = > > InitMilestone.JOB_LOADED) > > Use ItemListener.onLoaded. > > > 3. for each job do check whether new job property exists if not create > new > > one and move transient fields to it and then add new job property to the > job > > This is the only solution I have found to this kind of problem. For > example: > > > https://github.com/jenkinsci/jenkins/commit/f6b43d08af68b051f6335ebacfb5198d7467a1a7 > > It is a little worrisome adding such a task to startup, but all Item’s > are loaded in memory and quickly accessible, so if you are not making > any changes there should be no disk I/O and thus the overhead is > probably small. > > -- > 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]. > For more options, visit https://groups.google.com/d/optout. > -- 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]. For more options, visit https://groups.google.com/d/optout.
