aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakozak2011-11-24 09:09:46 (EST)
committerWinston Prakash2011-12-01 20:47:27 (EST)
commit24b7f7292cfdf87b89d1f317c101ba1109b878fa (patch)
treea3e580fbbc7532990bed6389585359a8390ea968
parentb6ce36bb22265f7918e95c300056dccf4bffc7b3 (diff)
downloadorg.eclipse.hudson.core-24b7f7292cfdf87b89d1f317c101ba1109b878fa.zip
org.eclipse.hudson.core-24b7f7292cfdf87b89d1f317c101ba1109b878fa.tar.gz
org.eclipse.hudson.core-24b7f7292cfdf87b89d1f317c101ba1109b878fa.tar.bz2
Fixed NPE
Signed-off-by: Winston Prakash <winston.prakash@gmail.com>
-rw-r--r--hudson-core/src/main/java/hudson/model/AbstractProject.java28
-rw-r--r--hudson-core/src/main/java/hudson/model/AppointedNode.java3
2 files changed, 25 insertions, 6 deletions
diff --git a/hudson-core/src/main/java/hudson/model/AbstractProject.java b/hudson-core/src/main/java/hudson/model/AbstractProject.java
index 422a0ed..07d288b 100644
--- a/hudson-core/src/main/java/hudson/model/AbstractProject.java
+++ b/hudson-core/src/main/java/hudson/model/AbstractProject.java
@@ -497,17 +497,28 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
/**
* Sets the assigned label.
+ * @param label node label.
+ *
+ * @throws java.io.IOException exception.
*/
- public void setAssignedLabel(Label l) throws IOException {
- getAppointedNode().setAssignedLabel(l);
+ public void setAssignedLabel(Label label) throws IOException {
+ AppointedNode node = getAppointedNode();
+ if(node == null){
+ node = new AppointedNode();
+ setAppointedNode(node);
+ }
+ node.setAssignedLabel(label);
save();
}
/**
* Assigns this job to the given node. A convenience method over {@link #setAssignedLabel(Label)}.
+ *
+ * @param node node.
+ * @throws java.io.IOException exception
*/
- public void setAssignedNode(Node l) throws IOException {
- setAssignedLabel(l.getSelfLabel());
+ public void setAssignedNode(Node node) throws IOException {
+ setAssignedLabel(node.getSelfLabel());
}
/**
@@ -525,12 +536,17 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
* Sets whether this project is using the advanced affinity chooser UI.
*
* @param b true - advanced chooser, false - otherwise
+ * @throws java.io.IOException exception.
*/
public void setAdvancedAffinityChooser(boolean b) throws IOException {
- getAppointedNode().setAdvancedAffinityChooser(b);
+ AppointedNode node = getAppointedNode();
+ if(node == null){
+ node = new AppointedNode();
+ setAppointedNode(node);
+ }
+ node.setAdvancedAffinityChooser(b);
save();
}
-
/**
* Sets {@link AppointedNode}.
*
diff --git a/hudson-core/src/main/java/hudson/model/AppointedNode.java b/hudson-core/src/main/java/hudson/model/AppointedNode.java
index d46f20c..b13e41d 100644
--- a/hudson-core/src/main/java/hudson/model/AppointedNode.java
+++ b/hudson-core/src/main/java/hudson/model/AppointedNode.java
@@ -44,6 +44,9 @@ public class AppointedNode implements Serializable {
*/
private volatile boolean canRoam;
+ public AppointedNode() {
+ }
+
public AppointedNode(String nodeName, Boolean advancedAffinityChooser) {
this.nodeName = nodeName;
this.advancedAffinityChooser = advancedAffinityChooser;