Skip to content
Browse files

Merge pull request #37 from kpfleming/ec2slave-support-old-data

Provide backwards compatibility for EC2Slave name change.
  • Loading branch information...
2 parents 7a64483 + fede71f commit 64a311d5dc20e3c2dd238f54375ca2d6d678c6db @francisu francisu committed Mar 5, 2013
Showing with 15 additions and 1 deletion.
  1. +15 −1 src/main/java/hudson/plugins/ec2/EC2Slave.java
View
16 src/main/java/hudson/plugins/ec2/EC2Slave.java
@@ -61,7 +61,7 @@
* @author Kohsuke Kawaguchi
*/
public final class EC2Slave extends Slave {
- public final String instanceId;
+ private String instanceId;
/**
* Comes from {@link SlaveTemplate#initScript}.
*/
@@ -123,6 +123,20 @@ public EC2Slave(String instanceId, String description, String remoteFS, int sshP
this.usePrivateDnsName = usePrivateDnsName;
}
+ protected Object readResolve() {
+ /*
+ * If instanceId is null, this object was deserialized from an old
+ * version of the plugin, where this field did not exist (prior to
+ * version 1.18). In those versions, the node name *was* the instance
+ * ID, so we can get it from there.
+ */
+ if (instanceId == null) {
+ instanceId = getNodeName();
+ }
+
+ return this;
+ }
+
/**
* Constructor for debugging.
*/

0 comments on commit 64a311d

Please sign in to comment.
Something went wrong with that request. Please try again.