Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: jenkinsci/jenkins
...
head fork: jenkinsci/jenkins
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
4 changelog.html
View
@@ -60,7 +60,9 @@
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
- <li class=>
+ <li class=bug>
+ Fixed a persistence problem in <tt>View$PropertyList</tt>
+ (<a href="http://issues.jenkins-ci.org/browse/JENKINS-9367">issue 9367</a>)
</ul>
</div><!--=TRUNK-END=-->
41 core/src/main/java/hudson/model/View.java
View
@@ -118,7 +118,7 @@
* List of {@link ViewProperty}s configured for this view.
* @since 1.406
*/
- private volatile DescribableList<ViewProperty,ViewPropertyDescriptor> properties = new PropertyList();
+ private volatile DescribableList<ViewProperty,ViewPropertyDescriptor> properties = new PropertyList(this);
protected View(String name) {
this.name = name;
@@ -129,13 +129,6 @@ protected View(String name, ViewGroup owner) {
this.owner = owner;
}
- private Object readResolve() {
- if (properties == null) {
- properties = new PropertyList();
- }
- return this;
- }
-
/**
* Gets all the items in this collection in a read-only view.
*/
@@ -204,6 +197,19 @@ public String getDescription() {
* @since 1.406
*/
public DescribableList<ViewProperty,ViewPropertyDescriptor> 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;
}
@@ -234,7 +240,7 @@ public void save() throws IOException {
*/
@Exported(name="property",inline=true)
public List<ViewProperty> getAllProperties() {
- return properties.toList();
+ return getProperties().toList();
}
public ViewDescriptor getDescriptor() {
@@ -635,7 +641,7 @@ public final synchronized void doConfigSubmit( StaplerRequest req, StaplerRespon
JSONObject json = req.getSubmittedForm();
- properties.rebuild(req, req.getSubmittedForm(), getApplicablePropertyDescriptors());
+ getProperties().rebuild(req, req.getSubmittedForm(), getApplicablePropertyDescriptors());
save();
@@ -762,15 +768,22 @@ public static View create(StaplerRequest req, StaplerResponse rsp, ViewGroup own
return v;
}
- private class PropertyList extends DescribableList<ViewProperty,ViewPropertyDescriptor> {
- private PropertyList() {
- super(View.this);
+ public static class PropertyList extends DescribableList<ViewProperty,ViewPropertyDescriptor> {
+ private PropertyList(View owner) {
+ super(owner);
+ }
+
+ public PropertyList() {// needed for XStream deserialization
+ }
+
+ public View getOwner() {
+ return (View)owner;
}
@Override
protected void onModified() throws IOException {
for (ViewProperty p : this)
- p.setView(View.this);
+ p.setView(getOwner());
}
}
}
10 test/src/test/java/hudson/model/ViewTest.java
View
@@ -118,4 +118,14 @@ public void testDeleteView() throws Exception {
assertNull(p.getView("list"));
}
+
+ @Bug(9367)
+ public void testPersistence() throws Exception {
+ ListView view = new ListView("foo", hudson);
+ hudson.addView(view);
+
+ ListView v = (ListView)Hudson.XSTREAM.fromXML(Hudson.XSTREAM.toXML(view));
+ System.out.println(v.getProperties());
+ assertNotNull(v.getProperties());
+ }
}

No commit comments for this range

Something went wrong with that request. Please try again.