From ce9ef803f73637677d08edd3ae1705d10f229d62 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Mon, 18 Apr 2011 09:52:46 -0700 Subject: [PATCH] [JENKINS-9367] revisting the fix --- changing the access modifier is an incompatible change. --- core/src/main/java/hudson/model/ListView.java | 3 +-- core/src/main/java/hudson/model/View.java | 26 +++++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/hudson/model/ListView.java b/core/src/main/java/hudson/model/ListView.java index 4167702551..e06110b0e2 100644 --- a/core/src/main/java/hudson/model/ListView.java +++ b/core/src/main/java/hudson/model/ListView.java @@ -91,8 +91,7 @@ public class ListView extends View implements Saveable { this.owner = owner; } - protected Object readResolve() { - super.readResolve(); + private Object readResolve() { if(includeRegex!=null) includePattern = Pattern.compile(includeRegex); initColumns(); diff --git a/core/src/main/java/hudson/model/View.java b/core/src/main/java/hudson/model/View.java index 4fc4a968e0..01279b90dc 100644 --- a/core/src/main/java/hudson/model/View.java +++ b/core/src/main/java/hudson/model/View.java @@ -129,15 +129,6 @@ public abstract class View extends AbstractModelObject implements AccessControll this.owner = owner; } - protected Object readResolve() { - if (properties == null) { - properties = new PropertyList(this); - } else { - properties.setOwner(this); - } - return this; - } - /** * Gets all the items in this collection in a read-only view. */ @@ -206,6 +197,19 @@ public abstract class View extends AbstractModelObject implements AccessControll * @since 1.406 */ public DescribableList getProperties() { + // readResolve was the best place to do this, but for compatibility reasons, + // this class can no longer have readResolve() (the mechanism itself isn't suitable for class hierarchy) + // see JENKINS-9431 + // + // until we have that, putting this logic here. + synchronized (this) { + if (properties == null) { + properties = new PropertyList(this); + } else { + properties.setOwner(this); + } + } + return properties; } @@ -236,7 +240,7 @@ public abstract class View extends AbstractModelObject implements AccessControll */ @Exported(name="property",inline=true) public List getAllProperties() { - return properties.toList(); + return getProperties().toList(); } public ViewDescriptor getDescriptor() { @@ -637,7 +641,7 @@ public abstract class View extends AbstractModelObject implements AccessControll JSONObject json = req.getSubmittedForm(); - properties.rebuild(req, req.getSubmittedForm(), getApplicablePropertyDescriptors()); + getProperties().rebuild(req, req.getSubmittedForm(), getApplicablePropertyDescriptors()); save();